<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
Authors: George Karachalias &lt;george.karachalias@cs.kuleuven.be&gt;
         Sebastian Graf &lt;sgraf1337@gmail.com&gt;
         Ryan Scott &lt;ryan.gl.scott@gmail.com&gt;
-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP, LambdaCase, TupleSections, PatternSynonyms, ViewPatterns, MultiWayIf #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-comment">-- | The pattern match oracle. The main export of the module are the functions</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- 'addPmCts' for adding facts to the oracle, and 'provideEvidence' to turn a</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- 'Delta' into a concrete evidence for an equation.</span><span>
</span><span id="line-12"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.HsToCore.PmCheck.Oracle</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier">DsM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier">tracePm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier">mkPmId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier">Delta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#initDeltas"><span class="hs-identifier">initDeltas</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupRefuts"><span class="hs-identifier">lookupRefuts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupSolution"><span class="hs-identifier">lookupSolution</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier">PmCt</span></a></span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTyCt"><span class="hs-identifier">PmTyCt</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCts"><span class="hs-identifier">PmCts</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmVarCt"><span class="hs-identifier">PmVarCt</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCoreCt"><span class="hs-identifier">PmCoreCt</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>        </span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmConCt"><span class="hs-identifier">PmConCt</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmNotConCt"><span class="hs-identifier">PmNotConCt</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmBotCt"><span class="hs-identifier">PmBotCt</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>        </span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmNotBotCt"><span class="hs-identifier">PmNotBotCt</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addPmCts"><span class="hs-identifier">addPmCts</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- Add a constraint to the oracle.</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#canDiverge"><span class="hs-identifier">canDiverge</span></a></span><span class="hs-special">,</span><span>         </span><span class="hs-comment">-- Try to add the term equality x ~ &#8869;</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#provideEvidence"><span class="hs-identifier">provideEvidence</span></a></span><span>
</span><span id="line-24"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html"><span class="hs-identifier">GHC.HsToCore.PmCheck.Types</span></a></span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.DSet.html"><span class="hs-identifier">GHC.Types.Unique.DSet</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.DFM.html"><span class="hs-identifier">GHC.Types.Unique.DFM</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier">EvVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html"><span class="hs-identifier">GHC.Core.FVs</span></a></span><span>       </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.FVs.html#exprFreeVars"><span class="hs-identifier">exprFreeVars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Map.html"><span class="hs-identifier">GHC.Core.Map</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.SimpleOpt.html"><span class="hs-identifier">GHC.Core.SimpleOpt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.SimpleOpt.html#simpleOptExpr"><span class="hs-identifier">simpleOptExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.SimpleOpt.html#exprIsConApp_maybe"><span class="hs-identifier">exprIsConApp_maybe</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier">exprType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Make.html"><span class="hs-identifier">GHC.Core.Make</span></a></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Make.html#mkListExpr"><span class="hs-identifier">mkListExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Make.html#mkCharExpr"><span class="hs-identifier">mkCharExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html"><span class="hs-identifier">GHC.Types.Unique.Supply</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html"><span class="hs-identifier">GHC.Core.ConLike</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.PatSyn.html"><span class="hs-identifier">GHC.Core.PatSyn</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.Prim.html"><span class="hs-identifier">GHC.Builtin.Types.Prim</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Builtin.Types.Prim.html#tYPETyCon"><span class="hs-identifier">tYPETyCon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html"><span class="hs-identifier">GHC.Tc.Solver</span></a></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Solver.html#tcNormalise"><span class="hs-identifier">tcNormalise</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#tcCheckSatisfiability"><span class="hs-identifier">tcCheckSatisfiability</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html"><span class="hs-identifier">GHC.Core.Unify</span></a></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTy"><span class="hs-identifier">tcMatchTy</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html"><span class="hs-identifier">GHC.Tc.Types</span></a></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Types.html#completeMatchConLikes"><span class="hs-identifier">completeMatchConLikes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html"><span class="hs-identifier">GHC.Utils.Monad</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier">foldlM</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.HsToCore.Monad.html"><span class="hs-identifier">GHC.HsToCore.Monad</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier">foldlM</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Family.html"><span class="hs-identifier">GHC.Tc.Instance.Family</span></a></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html"><span class="hs-identifier">GHC.Core.FamInstEnv</span></a></span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier">guard</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#mzero"><span class="hs-identifier">mzero</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier">when</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Class.html#"><span class="hs-identifier">Control.Monad.Trans.Class</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier">lift</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#"><span class="hs-identifier">Control.Monad.Trans.State.Strict</span></a></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bifunctor.html#"><span class="hs-identifier">Data.Bifunctor</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Bifunctor.html#second"><span class="hs-identifier">second</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-76"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#"><span class="hs-identifier">Data.Either</span></a></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#partitionEithers"><span class="hs-identifier">partitionEithers</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#"><span class="hs-identifier">Data.Foldable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier">foldlM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#minimumBy"><span class="hs-identifier">minimumBy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier">toList</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#find"><span class="hs-identifier">find</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-79"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Data.List.NonEmpty.html#"><span class="hs-identifier">Data.List.NonEmpty</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">NonEmpty</span></span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Ord.html#"><span class="hs-identifier">Data.Ord</span></a></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Ord.html#comparing"><span class="hs-identifier">comparing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Data.Semigroup.html#"><span class="hs-identifier">Data.Semigroup</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Semigroup</span></span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Tuple.html#"><span class="hs-identifier">Data.Tuple</span></a></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Tuple.html#swap"><span class="hs-identifier">swap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="hs-comment">-- Debugging Infrastructure</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-type">tracePm</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span id="tracePm"><span class="annot"><span class="annottext">tracePm :: String -&gt; SDoc -&gt; DsM ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-var hs-var">tracePm</span></a></span></span><span> </span><span id="local-6989586621681147196"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681147196"><span class="hs-identifier hs-var">herald</span></a></span></span><span> </span><span id="local-6989586621681147195"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681147195"><span class="hs-identifier hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-88"></span><span>  </span><span id="local-6989586621681147194"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681147194"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-89"></span><span>  </span><span id="local-6989586621681147192"><span class="annot"><span class="annottext">PrintUnqualified
</span><a href="#local-6989586621681147192"><span class="hs-identifier hs-var">printer</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM PrintUnqualified
</span><a href="GHC.HsToCore.Monad.html#mkPrintUnqualifiedDs"><span class="hs-identifier hs-var">mkPrintUnqualifiedDs</span></a></span><span>
</span><span id="line-90"></span><span>  </span><span class="annot"><span class="annottext">IO () -&gt; DsM ()
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; DsM ()) -&gt; IO () -&gt; DsM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">PrintUnqualified
-&gt; DynFlags -&gt; DumpFlag -&gt; String -&gt; DumpFormat -&gt; SDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#dumpIfSet_dyn_printer"><span class="hs-identifier hs-var">dumpIfSet_dyn_printer</span></a></span><span> </span><span class="annot"><span class="annottext">PrintUnqualified
</span><a href="#local-6989586621681147192"><span class="hs-identifier hs-var">printer</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681147194"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-91"></span><span>            </span><span class="annot"><span class="annottext">DumpFlag
</span><a href="GHC.Driver.Flags.html#Opt_D_dump_ec_trace"><span class="hs-identifier hs-var">Opt_D_dump_ec_trace</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">DumpFormat
</span><a href="GHC.Utils.Error.html#FormatText"><span class="hs-identifier hs-var">FormatText</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681147196"><span class="hs-identifier hs-var">herald</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681147195"><span class="hs-identifier hs-var">doc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-92"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-pragma hs-type">tracePm</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>  </span><span class="hs-comment">-- see Note [INLINE conditional tracing utilities]</span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-comment">-- | Generate a fresh `Id` of a given type</span><span>
</span><span id="line-95"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-type">mkPmId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-96"></span><span id="mkPmId"><span class="annot"><span class="annottext">mkPmId :: Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-var hs-var">mkPmId</span></a></span></span><span> </span><span id="local-6989586621681147183"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147183"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) Unique
forall (m :: * -&gt; *). MonadUnique m =&gt; m Unique
</span><a href="GHC.Types.Unique.Supply.html#getUniqueM"><span class="hs-identifier hs-var">getUniqueM</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) Unique
-&gt; (Unique -&gt; DsM Id) -&gt; DsM Id
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681147181"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681147181"><span class="hs-identifier hs-var">unique</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-97"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681147180"><span class="annot"><span class="annottext">occname :: OccName
</span><a href="#local-6989586621681147180"><span class="hs-identifier hs-var hs-var">occname</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkVarOccFS"><span class="hs-identifier hs-var">mkVarOccFS</span></a></span><span> </span><span class="annot"><span class="annottext">(FastString -&gt; OccName) -&gt; FastString -&gt; OccName
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;pm&quot;</span></span><span>
</span><span id="line-98"></span><span>      </span><span id="local-6989586621681147177"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681147177"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; SrcSpan -&gt; Name
</span><a href="GHC.Types.Name.html#mkInternalName"><span class="hs-identifier hs-var">mkInternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681147181"><span class="hs-identifier hs-var">unique</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681147180"><span class="hs-identifier hs-var">occname</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="GHC.Types.SrcLoc.html#noSrcSpan"><span class="hs-identifier hs-var">noSrcSpan</span></a></span><span>
</span><span id="line-99"></span><span>  </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">Id -&gt; DsM Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; Type -&gt; Id
</span><a href="GHC.Types.Id.html#mkLocalIdOrCoVar"><span class="hs-identifier hs-var">mkLocalIdOrCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681147177"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147183"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span><span class="hs-comment">-----------------------------------------------</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- * Caching possible matches of a COMPLETE set</span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#markMatched"><span class="hs-identifier hs-type">markMatched</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PossibleMatches"><span class="hs-identifier hs-type">PossibleMatches</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PossibleMatches"><span class="hs-identifier hs-type">PossibleMatches</span></a></span><span>
</span><span id="line-105"></span><span id="markMatched"><span class="annot"><span class="annottext">markMatched :: ConLike -&gt; PossibleMatches -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#markMatched"><span class="hs-identifier hs-var hs-var">markMatched</span></a></span></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#NoPM"><span class="hs-identifier hs-var">NoPM</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#NoPM"><span class="hs-identifier hs-var">NoPM</span></a></span><span>
</span><span id="line-106"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#markMatched"><span class="hs-identifier hs-var">markMatched</span></a></span><span> </span><span id="local-6989586621681147170"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681147170"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PM"><span class="hs-identifier hs-type">PM</span></a></span><span> </span><span id="local-6989586621681147168"><span class="annot"><span class="annottext">NonEmpty ConLikeSet
</span><a href="#local-6989586621681147168"><span class="hs-identifier hs-var">ms</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NonEmpty ConLikeSet -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#PM"><span class="hs-identifier hs-var">PM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; ConLikeSet -&gt; ConLikeSet
</span><a href="#local-6989586621681147167"><span class="hs-identifier hs-var">del_one_con</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681147170"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">(ConLikeSet -&gt; ConLikeSet)
-&gt; NonEmpty ConLikeSet -&gt; NonEmpty ConLikeSet
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty ConLikeSet
</span><a href="#local-6989586621681147168"><span class="hs-identifier hs-var">ms</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-108"></span><span>    </span><span id="local-6989586621681147167"><span class="annot"><span class="annottext">del_one_con :: ConLike -&gt; ConLikeSet -&gt; ConLikeSet
</span><a href="#local-6989586621681147167"><span class="hs-identifier hs-var hs-var">del_one_con</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ConLikeSet -&gt; ConLike -&gt; ConLikeSet)
-&gt; ConLike -&gt; ConLikeSet -&gt; ConLikeSet
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">ConLikeSet -&gt; ConLike -&gt; ConLikeSet
forall a. Uniquable a =&gt; UniqDSet a -&gt; a -&gt; UniqDSet a
</span><a href="GHC.Types.Unique.DSet.html#delOneFromUniqDSet"><span class="hs-identifier hs-var">delOneFromUniqDSet</span></a></span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span class="hs-comment">---------------------------------------------------</span><span>
</span><span id="line-111"></span><span class="hs-comment">-- * Instantiating constructors, types and evidence</span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span class="hs-comment">-- | Instantiate a 'ConLike' given its universal type arguments. Instantiates</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- existential and term binders with fresh variables of appropriate type.</span><span>
</span><span id="line-115"></span><span class="hs-comment">-- Returns instantiated type and term variables from the match, type evidence</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- and the types of strict constructor fields.</span><span>
</span><span id="line-117"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#mkOneConFull"><span class="hs-identifier hs-type">mkOneConFull</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TyCt"><span class="hs-identifier hs-type">TyCt</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span class="hs-comment">--  * 'con' K is a ConLike</span><span>
</span><span id="line-119"></span><span class="hs-comment">--       - In the case of DataCons and most PatSynCons, these</span><span>
</span><span id="line-120"></span><span class="hs-comment">--         are associated with a particular TyCon T</span><span>
</span><span id="line-121"></span><span class="hs-comment">--       - But there are PatSynCons for this is not the case! See #11336, #17112</span><span>
</span><span id="line-122"></span><span class="hs-comment">--</span><span>
</span><span id="line-123"></span><span class="hs-comment">--  * 'arg_tys' tys are the types K's universally quantified type</span><span>
</span><span id="line-124"></span><span class="hs-comment">--     variables should be instantiated to.</span><span>
</span><span id="line-125"></span><span class="hs-comment">--       - For DataCons and most PatSyns these are the arguments of their TyCon</span><span>
</span><span id="line-126"></span><span class="hs-comment">--       - For cases like the PatSyns in #11336, #17112, we can't easily guess</span><span>
</span><span id="line-127"></span><span class="hs-comment">--         these, so don't call this function.</span><span>
</span><span id="line-128"></span><span class="hs-comment">--</span><span>
</span><span id="line-129"></span><span class="hs-comment">-- After instantiating the universal tyvars of K to tys we get</span><span>
</span><span id="line-130"></span><span class="hs-comment">--          K @tys :: forall bs. Q =&gt; s1 .. sn -&gt; T tys</span><span>
</span><span id="line-131"></span><span class="hs-comment">-- Note that if K is a PatSynCon, depending on arg_tys, T might not necessarily</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- be a concrete TyCon.</span><span>
</span><span id="line-133"></span><span class="hs-comment">--</span><span>
</span><span id="line-134"></span><span class="hs-comment">-- Suppose y1 is a strict field. Then we get</span><span>
</span><span id="line-135"></span><span class="hs-comment">-- Results: bs</span><span>
</span><span id="line-136"></span><span class="hs-comment">--          [y1,..,yn]</span><span>
</span><span id="line-137"></span><span class="hs-comment">--          Q</span><span>
</span><span id="line-138"></span><span class="hs-comment">--          [s1]</span><span>
</span><span id="line-139"></span><span id="mkOneConFull"><span class="annot"><span class="annottext">mkOneConFull :: [Type] -&gt; ConLike -&gt; DsM ([Id], [Id], Bag Type, [Type])
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkOneConFull"><span class="hs-identifier hs-var hs-var">mkOneConFull</span></a></span></span><span> </span><span id="local-6989586621681147159"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147159"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span> </span><span id="local-6989586621681147158"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681147158"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-140"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681147157"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681147157"><span class="hs-identifier hs-var">univ_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147156"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681147156"><span class="hs-identifier hs-var">ex_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147155"><span class="annot"><span class="annottext">[EqSpec]
</span><a href="#local-6989586621681147155"><span class="hs-identifier hs-var">eq_spec</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147154"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147154"><span class="hs-identifier hs-var">thetas</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147153"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147153"><span class="hs-identifier hs-var">_req_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147152"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681147152"><span class="hs-identifier hs-var">field_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147151"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147151"><span class="hs-identifier hs-var">_con_res_ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-141"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConLike
-&gt; ([Id], [Id], [EqSpec], [Type], [Type], [Scaled Type], Type)
</span><a href="GHC.Core.ConLike.html#conLikeFullSig"><span class="hs-identifier hs-var">conLikeFullSig</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681147158"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-142"></span><span>  </span><span class="hs-comment">-- pprTrace &quot;mkOneConFull&quot; (ppr con $$ ppr arg_tys $$ ppr univ_tvs $$ ppr _con_res_ty) (return ())</span><span>
</span><span id="line-143"></span><span>  </span><span class="hs-comment">-- Substitute universals for type arguments</span><span>
</span><span id="line-144"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681147148"><span class="annot"><span class="annottext">subst_univ :: TCvSubst
</span><a href="#local-6989586621681147148"><span class="hs-identifier hs-var hs-var">subst_univ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Type] -&gt; TCvSubst
HasDebugCallStack =&gt; [Id] -&gt; [Type] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-var">zipTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681147157"><span class="hs-identifier hs-var">univ_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147159"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-145"></span><span>  </span><span class="hs-comment">-- Instantiate fresh existentials as arguments to the constructor. This is</span><span>
</span><span id="line-146"></span><span>  </span><span class="hs-comment">-- important for instantiating the Thetas and field types.</span><span>
</span><span id="line-147"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621681147146"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681147146"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Id] -&gt; UniqSupply -&gt; (TCvSubst, [Id])
</span><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndrs"><span class="hs-identifier hs-var">cloneTyVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681147148"><span class="hs-identifier hs-var">subst_univ</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681147156"><span class="hs-identifier hs-var">ex_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">(UniqSupply -&gt; (TCvSubst, [Id]))
-&gt; IOEnv (Env DsGblEnv DsLclEnv) UniqSupply
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (TCvSubst, [Id])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) UniqSupply
forall (m :: * -&gt; *). MonadUnique m =&gt; m UniqSupply
</span><a href="GHC.Types.Unique.Supply.html#getUniqueSupplyM"><span class="hs-identifier hs-var">getUniqueSupplyM</span></a></span><span>
</span><span id="line-148"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681147141"><span class="annot"><span class="annottext">field_tys' :: [Type]
</span><a href="#local-6989586621681147141"><span class="hs-identifier hs-var hs-var">field_tys'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; [Type] -&gt; [Type]
TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier hs-var">substTys</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681147146"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; [Type]) -&gt; [Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Scaled Type -&gt; Type) -&gt; [Scaled Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681147152"><span class="hs-identifier hs-var">field_tys</span></a></span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-comment">-- Instantiate fresh term variables (VAs) as arguments to the constructor</span><span>
</span><span id="line-150"></span><span>  </span><span id="local-6989586621681147138"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681147138"><span class="hs-identifier hs-var">vars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; DsM Id) -&gt; [Type] -&gt; IOEnv (Env DsGblEnv DsLclEnv) [Id]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-var">mkPmId</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147141"><span class="hs-identifier hs-var">field_tys'</span></a></span><span>
</span><span id="line-151"></span><span>  </span><span class="hs-comment">-- All constraints bound by the constructor (alpha-renamed), these are added</span><span>
</span><span id="line-152"></span><span>  </span><span class="hs-comment">-- to the type oracle</span><span>
</span><span id="line-153"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681147134"><span class="annot"><span class="annottext">ty_cs :: [Type]
</span><a href="#local-6989586621681147134"><span class="hs-identifier hs-var hs-var">ty_cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; [Type] -&gt; [Type]
TCvSubst -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var">substTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681147146"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[EqSpec] -&gt; [Type]
</span><a href="GHC.Core.DataCon.html#eqSpecPreds"><span class="hs-identifier hs-var">eqSpecPreds</span></a></span><span> </span><span class="annot"><span class="annottext">[EqSpec]
</span><a href="#local-6989586621681147155"><span class="hs-identifier hs-var">eq_spec</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147154"><span class="hs-identifier hs-var">thetas</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>  </span><span class="hs-comment">-- Figure out the types of strict constructor fields</span><span>
</span><span id="line-155"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681147131"><span class="annot"><span class="annottext">arg_is_strict :: [Bool]
</span><a href="#local-6989586621681147131"><span class="hs-identifier hs-var hs-var">arg_is_strict</span></a></span></span><span>
</span><span id="line-156"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span id="local-6989586621681147129"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681147129"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681147158"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-157"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isNewTyCon"><span class="hs-identifier hs-var">isNewTyCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; TyCon
</span><a href="GHC.Core.DataCon.html#dataConTyCon"><span class="hs-identifier hs-var">dataConTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681147129"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-158"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- See Note [Divergence of Newtype matches]</span><span>
</span><span id="line-159"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-160"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(HsImplBang -&gt; Bool) -&gt; [HsImplBang] -&gt; [Bool]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">HsImplBang -&gt; Bool
</span><a href="GHC.Core.DataCon.html#isBanged"><span class="hs-identifier hs-var">isBanged</span></a></span><span> </span><span class="annot"><span class="annottext">([HsImplBang] -&gt; [Bool]) -&gt; [HsImplBang] -&gt; [Bool]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike -&gt; [HsImplBang]
</span><a href="GHC.Core.ConLike.html#conLikeImplBangs"><span class="hs-identifier hs-var">conLikeImplBangs</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681147158"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-161"></span><span>      </span><span id="local-6989586621681147124"><span class="annot"><span class="annottext">strict_arg_tys :: [Type]
</span><a href="#local-6989586621681147124"><span class="hs-identifier hs-var hs-var">strict_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Bool] -&gt; [Type] -&gt; [Type]
forall a. [Bool] -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#filterByList"><span class="hs-identifier hs-var">filterByList</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681147131"><span class="hs-identifier hs-var">arg_is_strict</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147141"><span class="hs-identifier hs-var">field_tys'</span></a></span><span>
</span><span id="line-162"></span><span>  </span><span class="annot"><span class="annottext">([Id], [Id], Bag Type, [Type])
-&gt; DsM ([Id], [Id], Bag Type, [Type])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681147156"><span class="hs-identifier hs-var">ex_tvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681147138"><span class="hs-identifier hs-var">vars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Bag Type
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147134"><span class="hs-identifier hs-var">ty_cs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147124"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span class="hs-comment">-------------------------</span><span>
</span><span id="line-165"></span><span class="hs-comment">-- * Pattern match oracle</span><span>
</span><span id="line-166"></span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span class="hs-comment">{- Note [Recovering from unsatisfiable pattern-matching constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider the following code (see #12957 and #15450):

  f :: Int ~ Bool =&gt; ()
  f = case True of { False -&gt; () }

We want to warn that the pattern-matching in `f` is non-exhaustive. But GHC
used not to do this; in fact, it would warn that the match was /redundant/!
This is because the constraint (Int ~ Bool) in `f` is unsatisfiable, and the
coverage checker deems any matches with unsatisfiable constraint sets to be
unreachable.

We decide to better than this. When beginning coverage checking, we first
check if the constraints in scope are unsatisfiable, and if so, we start
afresh with an empty set of constraints. This way, we'll get the warnings
that we expect.
-}</span><span>
</span><span id="line-186"></span><span>
</span><span id="line-187"></span><span class="hs-comment">-------------------------------------</span><span>
</span><span id="line-188"></span><span class="hs-comment">-- * Composable satisfiability checks</span><span>
</span><span id="line-189"></span><span>
</span><span id="line-190"></span><span class="hs-comment">-- | Given a 'Delta', check if it is compatible with new facts encoded in this</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- this check. If so, return 'Just' a potentially extended 'Delta'. Return</span><span>
</span><span id="line-192"></span><span class="hs-comment">-- 'Nothing' if unsatisfiable.</span><span>
</span><span id="line-193"></span><span class="hs-comment">--</span><span>
</span><span id="line-194"></span><span class="hs-comment">-- There are three essential SatisfiabilityChecks:</span><span>
</span><span id="line-195"></span><span class="hs-comment">--   1. 'tmIsSatisfiable', adding term oracle facts</span><span>
</span><span id="line-196"></span><span class="hs-comment">--   2. 'tyIsSatisfiable', adding type oracle facts</span><span>
</span><span id="line-197"></span><span class="hs-comment">--   3. 'tysAreNonVoid', checks if the given types have an inhabitant</span><span>
</span><span id="line-198"></span><span class="hs-comment">-- Functions like 'pmIsSatisfiable', 'nonVoid' and 'testInhabited' plug these</span><span>
</span><span id="line-199"></span><span class="hs-comment">-- together as they see fit.</span><span>
</span><span id="line-200"></span><span class="hs-keyword">newtype</span><span> </span><span id="SatisfiabilityCheck"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SatisfiabilityCheck"><span class="hs-identifier hs-var">SatisfiabilityCheck</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="SC"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-var">SC</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="hs-comment">-- | Check the given 'Delta' for satisfiability by the given</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- 'SatisfiabilityCheck'. Return 'Just' a new, potentially extended, 'Delta' if</span><span>
</span><span id="line-204"></span><span class="hs-comment">-- successful, and 'Nothing' otherwise.</span><span>
</span><span id="line-205"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#runSatisfiabilityCheck"><span class="hs-identifier hs-type">runSatisfiabilityCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SatisfiabilityCheck"><span class="hs-identifier hs-type">SatisfiabilityCheck</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-206"></span><span id="runSatisfiabilityCheck"><span class="annot"><span class="annottext">runSatisfiabilityCheck :: Delta -&gt; SatisfiabilityCheck -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#runSatisfiabilityCheck"><span class="hs-identifier hs-var hs-var">runSatisfiabilityCheck</span></a></span></span><span> </span><span id="local-6989586621681147119"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681147119"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-type">SC</span></a></span><span> </span><span id="local-6989586621681147118"><span class="annot"><span class="annottext">Delta -&gt; DsM (Maybe Delta)
</span><a href="#local-6989586621681147118"><span class="hs-identifier hs-var">chk</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; DsM (Maybe Delta)
</span><a href="#local-6989586621681147118"><span class="hs-identifier hs-var">chk</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681147119"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-207"></span><span>
</span><span id="line-208"></span><span class="hs-comment">-- | Allowing easy composition of 'SatisfiabilityCheck's.</span><span>
</span><span id="line-209"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681147113"><span id="local-6989586621681147115"><span class="annot"><a href="../../base/src/GHC.Base.html#Semigroup"><span class="hs-identifier hs-type">Semigroup</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SatisfiabilityCheck"><span class="hs-identifier hs-type">SatisfiabilityCheck</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-210"></span><span>  </span><span class="hs-comment">-- This is @a &gt;=&gt; b@ from MaybeT DsM</span><span>
</span><span id="line-211"></span><span>  </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-type">SC</span></a></span><span> </span><span id="local-6989586621681147111"><span class="annot"><span class="annottext">Delta -&gt; DsM (Maybe Delta)
</span><a href="#local-6989586621681147111"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681147110"><span class="annot"><span class="annottext">&lt;&gt; :: SatisfiabilityCheck -&gt; SatisfiabilityCheck -&gt; SatisfiabilityCheck
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;&gt;</span></a></span></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-type">SC</span></a></span><span> </span><span id="local-6989586621681147109"><span class="annot"><span class="annottext">Delta -&gt; DsM (Maybe Delta)
</span><a href="#local-6989586621681147109"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-var">SC</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; DsM (Maybe Delta)
</span><a href="#local-6989586621681147108"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-212"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-213"></span><span>      </span><span id="local-6989586621681147108"><span class="annot"><span class="annottext">c :: Delta -&gt; DsM (Maybe Delta)
</span><a href="#local-6989586621681147108"><span class="hs-identifier hs-var hs-var">c</span></a></span></span><span> </span><span id="local-6989586621681147105"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681147105"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; DsM (Maybe Delta)
</span><a href="#local-6989586621681147111"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681147105"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">DsM (Maybe Delta)
-&gt; (Maybe Delta -&gt; DsM (Maybe Delta)) -&gt; DsM (Maybe Delta)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-glyph">case</span><span>
</span><span id="line-214"></span><span>        </span><span class="annot"><span class="annottext">Maybe Delta
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Delta -&gt; DsM (Maybe Delta)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Delta
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-215"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681147104"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681147104"><span class="hs-identifier hs-var">delta'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; DsM (Maybe Delta)
</span><a href="#local-6989586621681147109"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681147104"><span class="hs-identifier hs-var">delta'</span></a></span><span>
</span><span id="line-216"></span><span>
</span><span id="line-217"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681147097"><span id="local-6989586621681147099"><span class="annot"><a href="../../base/src/GHC.Base.html#Monoid"><span class="hs-identifier hs-type">Monoid</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SatisfiabilityCheck"><span class="hs-identifier hs-type">SatisfiabilityCheck</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-218"></span><span>  </span><span class="hs-comment">-- We only need this because of mconcat (which we use in place of sconcat,</span><span>
</span><span id="line-219"></span><span>  </span><span class="hs-comment">-- which requires NonEmpty lists as argument, making all call sites ugly)</span><span>
</span><span id="line-220"></span><span>  </span><span id="local-6989586621681147094"><span class="annot"><span class="annottext">mempty :: SatisfiabilityCheck
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var hs-var hs-var hs-var">mempty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-var">SC</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Delta -&gt; DsM (Maybe Delta)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Delta -&gt; DsM (Maybe Delta))
-&gt; (Delta -&gt; Maybe Delta) -&gt; Delta -&gt; DsM (Maybe Delta)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Maybe Delta
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span class="hs-comment">-------------------------------</span><span>
</span><span id="line-223"></span><span class="hs-comment">-- * Oracle transition function</span><span>
</span><span id="line-224"></span><span>
</span><span id="line-225"></span><span class="hs-comment">-- | Given a conlike's term constraints, type constraints, and strict argument</span><span>
</span><span id="line-226"></span><span class="hs-comment">-- types, check if they are satisfiable.</span><span>
</span><span id="line-227"></span><span class="hs-comment">-- (In other words, this is the &#8866;_Sat oracle judgment from the GADTs Meet</span><span>
</span><span id="line-228"></span><span class="hs-comment">-- Their Match paper.)</span><span>
</span><span id="line-229"></span><span class="hs-comment">--</span><span>
</span><span id="line-230"></span><span class="hs-comment">-- Taking strict argument types into account is something which was not</span><span>
</span><span id="line-231"></span><span class="hs-comment">-- discussed in GADTs Meet Their Match. For an explanation of what role they</span><span>
</span><span id="line-232"></span><span class="hs-comment">-- serve, see @Note [Strict argument type constraints]@.</span><span>
</span><span id="line-233"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#pmIsSatisfiable"><span class="hs-identifier hs-type">pmIsSatisfiable</span></a></span><span>
</span><span id="line-234"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>       </span><span class="hs-comment">-- ^ The ambient term and type constraints</span><span>
</span><span id="line-235"></span><span>                 </span><span class="hs-comment">--   (known to be satisfiable).</span><span>
</span><span id="line-236"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TyCt"><span class="hs-identifier hs-type">TyCt</span></a></span><span>    </span><span class="hs-comment">-- ^ The new type constraints.</span><span>
</span><span id="line-237"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCt"><span class="hs-identifier hs-type">TmCt</span></a></span><span>    </span><span class="hs-comment">-- ^ The new term constraints.</span><span>
</span><span id="line-238"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- ^ The strict argument types.</span><span>
</span><span id="line-239"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-240"></span><span>                 </span><span class="hs-comment">-- ^ @'Just' delta@ if the constraints (@delta@) are</span><span>
</span><span id="line-241"></span><span>                 </span><span class="hs-comment">-- satisfiable, and each strict argument type is inhabitable.</span><span>
</span><span id="line-242"></span><span>                 </span><span class="hs-comment">-- 'Nothing' otherwise.</span><span>
</span><span id="line-243"></span><span id="pmIsSatisfiable"><span class="annot"><span class="annottext">pmIsSatisfiable :: Delta -&gt; Bag Type -&gt; Bag TmCt -&gt; [Type] -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmIsSatisfiable"><span class="hs-identifier hs-var hs-var">pmIsSatisfiable</span></a></span></span><span> </span><span id="local-6989586621681147091"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681147091"><span class="hs-identifier hs-var">amb_cs</span></a></span></span><span> </span><span id="local-6989586621681147090"><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681147090"><span class="hs-identifier hs-var">new_ty_cs</span></a></span></span><span> </span><span id="local-6989586621681147089"><span class="annot"><span class="annottext">Bag TmCt
</span><a href="#local-6989586621681147089"><span class="hs-identifier hs-var">new_tm_cs</span></a></span></span><span> </span><span id="local-6989586621681147088"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147088"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-244"></span><span>  </span><span class="hs-comment">-- The order is important here! Check the new type constraints before we check</span><span>
</span><span id="line-245"></span><span>  </span><span class="hs-comment">-- whether strict argument types are inhabited given those constraints.</span><span>
</span><span id="line-246"></span><span>  </span><span class="annot"><span class="annottext">Delta -&gt; SatisfiabilityCheck -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#runSatisfiabilityCheck"><span class="hs-identifier hs-var">runSatisfiabilityCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681147091"><span class="hs-identifier hs-var">amb_cs</span></a></span><span> </span><span class="annot"><span class="annottext">(SatisfiabilityCheck -&gt; DsM (Maybe Delta))
-&gt; SatisfiabilityCheck -&gt; DsM (Maybe Delta)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SatisfiabilityCheck] -&gt; SatisfiabilityCheck
forall a. Monoid a =&gt; [a] -&gt; a
</span><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var">mconcat</span></a></span><span>
</span><span id="line-247"></span><span>    </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bag Type -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tyIsSatisfiable"><span class="hs-identifier hs-var">tyIsSatisfiable</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681147090"><span class="hs-identifier hs-var">new_ty_cs</span></a></span><span>
</span><span id="line-248"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag TmCt -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tmIsSatisfiable"><span class="hs-identifier hs-var">tmIsSatisfiable</span></a></span><span> </span><span class="annot"><span class="annottext">Bag TmCt
</span><a href="#local-6989586621681147089"><span class="hs-identifier hs-var">new_tm_cs</span></a></span><span>
</span><span id="line-249"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; [Type] -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tysAreNonVoid"><span class="hs-identifier hs-var">tysAreNonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="GHC.Core.TyCon.html#initRecTc"><span class="hs-identifier hs-var">initRecTc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147088"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span>
</span><span id="line-250"></span><span>    </span><span class="hs-special">]</span><span>
</span><span id="line-251"></span><span>
</span><span id="line-252"></span><span class="hs-comment">-----------------------</span><span>
</span><span id="line-253"></span><span class="hs-comment">-- * Type normalisation</span><span>
</span><span id="line-254"></span><span>
</span><span id="line-255"></span><span class="hs-comment">-- | The return value of 'pmTopNormaliseType'</span><span>
</span><span id="line-256"></span><span class="hs-keyword">data</span><span> </span><span id="TopNormaliseTypeResult"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TopNormaliseTypeResult"><span class="hs-identifier hs-var">TopNormaliseTypeResult</span></a></span></span><span>
</span><span id="line-257"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="NoChange"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NoChange"><span class="hs-identifier hs-var">NoChange</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-258"></span><span>  </span><span class="hs-comment">-- ^ 'tcNormalise' failed to simplify the type and 'topNormaliseTypeX' was</span><span>
</span><span id="line-259"></span><span>  </span><span class="hs-comment">-- unable to reduce the outermost type application, so the type came out</span><span>
</span><span id="line-260"></span><span>  </span><span class="hs-comment">-- unchanged.</span><span>
</span><span id="line-261"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="NormalisedByConstraints"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NormalisedByConstraints"><span class="hs-identifier hs-var">NormalisedByConstraints</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-262"></span><span>  </span><span class="hs-comment">-- ^ 'tcNormalise' was able to simplify the type with some local constraint</span><span>
</span><span id="line-263"></span><span>  </span><span class="hs-comment">-- from the type oracle, but 'topNormaliseTypeX' couldn't identify a type</span><span>
</span><span id="line-264"></span><span>  </span><span class="hs-comment">-- redex.</span><span>
</span><span id="line-265"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="HadRedexes"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#HadRedexes"><span class="hs-identifier hs-var">HadRedexes</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-266"></span><span>  </span><span class="hs-comment">-- ^ 'tcNormalise' may or may not been able to simplify the type, but</span><span>
</span><span id="line-267"></span><span>  </span><span class="hs-comment">-- 'topNormaliseTypeX' made progress either way and got rid of at least one</span><span>
</span><span id="line-268"></span><span>  </span><span class="hs-comment">-- outermost type or data family redex or newtype.</span><span>
</span><span id="line-269"></span><span>  </span><span class="hs-comment">-- The first field is the last type that was reduced solely through type</span><span>
</span><span id="line-270"></span><span>  </span><span class="hs-comment">-- family applications (possibly just the 'tcNormalise'd type). This is the</span><span>
</span><span id="line-271"></span><span>  </span><span class="hs-comment">-- one that is equal (in source Haskell) to the initial type.</span><span>
</span><span id="line-272"></span><span>  </span><span class="hs-comment">-- The third field is the type that we get when also looking through data</span><span>
</span><span id="line-273"></span><span>  </span><span class="hs-comment">-- family applications and newtypes. This would be the representation type in</span><span>
</span><span id="line-274"></span><span>  </span><span class="hs-comment">-- Core (modulo casts).</span><span>
</span><span id="line-275"></span><span>  </span><span class="hs-comment">-- The second field is the list of Newtype 'DataCon's that we looked through</span><span>
</span><span id="line-276"></span><span>  </span><span class="hs-comment">-- in the chain of reduction steps between the Source type and the Core type.</span><span>
</span><span id="line-277"></span><span>  </span><span class="hs-comment">-- We also keep the type of the DataCon application and its field, so that we</span><span>
</span><span id="line-278"></span><span>  </span><span class="hs-comment">-- don't have to reconstruct it in 'inhabitationCandidates' and</span><span>
</span><span id="line-279"></span><span>  </span><span class="hs-comment">-- 'provideEvidence'.</span><span>
</span><span id="line-280"></span><span>  </span><span class="hs-comment">-- For an example, see Note [Type normalisation].</span><span>
</span><span id="line-281"></span><span>
</span><span id="line-282"></span><span class="hs-comment">-- | Just give me the potentially normalised source type, unchanged or not!</span><span>
</span><span id="line-283"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#normalisedSourceType"><span class="hs-identifier hs-type">normalisedSourceType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TopNormaliseTypeResult"><span class="hs-identifier hs-type">TopNormaliseTypeResult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-284"></span><span id="normalisedSourceType"><span class="annot"><span class="annottext">normalisedSourceType :: TopNormaliseTypeResult -&gt; Type
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#normalisedSourceType"><span class="hs-identifier hs-var hs-var">normalisedSourceType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NoChange"><span class="hs-identifier hs-type">NoChange</span></a></span><span> </span><span id="local-6989586621681147079"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147079"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147079"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-285"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#normalisedSourceType"><span class="hs-identifier hs-var">normalisedSourceType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NormalisedByConstraints"><span class="hs-identifier hs-type">NormalisedByConstraints</span></a></span><span> </span><span id="local-6989586621681147078"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147078"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147078"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-286"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#normalisedSourceType"><span class="hs-identifier hs-var">normalisedSourceType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#HadRedexes"><span class="hs-identifier hs-type">HadRedexes</span></a></span><span> </span><span id="local-6989586621681147077"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147077"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147077"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-287"></span><span>
</span><span id="line-288"></span><span class="hs-comment">-- | Return the fields of 'HadRedexes'. Returns appropriate defaults in the</span><span>
</span><span id="line-289"></span><span class="hs-comment">-- other cases.</span><span>
</span><span id="line-290"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tntrGuts"><span class="hs-identifier hs-type">tntrGuts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TopNormaliseTypeResult"><span class="hs-identifier hs-type">TopNormaliseTypeResult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-291"></span><span id="tntrGuts"><span class="annot"><span class="annottext">tntrGuts :: TopNormaliseTypeResult -&gt; (Type, [(Type, DataCon, Type)], Type)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tntrGuts"><span class="hs-identifier hs-var hs-var">tntrGuts</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NoChange"><span class="hs-identifier hs-type">NoChange</span></a></span><span> </span><span id="local-6989586621681147075"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147075"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147075"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span>     </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span>      </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147075"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-292"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tntrGuts"><span class="hs-identifier hs-var">tntrGuts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NormalisedByConstraints"><span class="hs-identifier hs-type">NormalisedByConstraints</span></a></span><span> </span><span id="local-6989586621681147074"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147074"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147074"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span>     </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span>      </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147074"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tntrGuts"><span class="hs-identifier hs-var">tntrGuts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#HadRedexes"><span class="hs-identifier hs-type">HadRedexes</span></a></span><span> </span><span id="local-6989586621681147073"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147073"><span class="hs-identifier hs-var">src_ty</span></a></span></span><span> </span><span id="local-6989586621681147072"><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681147072"><span class="hs-identifier hs-var">ds</span></a></span></span><span> </span><span id="local-6989586621681147071"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147071"><span class="hs-identifier hs-var">core_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147073"><span class="hs-identifier hs-var">src_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681147072"><span class="hs-identifier hs-var">ds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147071"><span class="hs-identifier hs-var">core_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681147068"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TopNormaliseTypeResult"><span class="hs-identifier hs-type">TopNormaliseTypeResult</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-296"></span><span>  </span><span id="local-6989586621681147064"><span class="annot"><span class="annottext">ppr :: TopNormaliseTypeResult -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NoChange"><span class="hs-identifier hs-type">NoChange</span></a></span><span> </span><span id="local-6989586621681147062"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147062"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;NoChange&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147062"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-297"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NormalisedByConstraints"><span class="hs-identifier hs-type">NormalisedByConstraints</span></a></span><span> </span><span id="local-6989586621681147060"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147060"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;NormalisedByConstraints&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147060"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-298"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#HadRedexes"><span class="hs-identifier hs-type">HadRedexes</span></a></span><span> </span><span id="local-6989586621681147059"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147059"><span class="hs-identifier hs-var">src_ty</span></a></span></span><span> </span><span id="local-6989586621681147058"><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681147058"><span class="hs-identifier hs-var">ds</span></a></span></span><span> </span><span id="local-6989586621681147057"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147057"><span class="hs-identifier hs-var">core_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;HadRedexes&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681147055"><span class="hs-identifier hs-var">fields</span></a></span><span>
</span><span id="line-299"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-300"></span><span>      </span><span id="local-6989586621681147055"><span class="annot"><span class="annottext">fields :: SDoc
</span><a href="#local-6989586621681147055"><span class="hs-identifier hs-var hs-var">fields</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#fsep"><span class="hs-identifier hs-var">fsep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
</span><a href="GHC.Utils.Outputable.html#punctuate"><span class="hs-identifier hs-var">punctuate</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;src_ty =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147059"><span class="hs-identifier hs-var">src_ty</span></a></span><span>
</span><span id="line-301"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newtype_dcs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681147058"><span class="hs-identifier hs-var">ds</span></a></span><span>
</span><span id="line-302"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;core_ty =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147057"><span class="hs-identifier hs-var">core_ty</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#pmTopNormaliseType"><span class="hs-identifier hs-type">pmTopNormaliseType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TyState"><span class="hs-identifier hs-type">TyState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TopNormaliseTypeResult"><span class="hs-identifier hs-type">TopNormaliseTypeResult</span></a></span><span>
</span><span id="line-305"></span><span class="hs-comment">-- ^ Get rid of *outermost* (or toplevel)</span><span>
</span><span id="line-306"></span><span class="hs-comment">--      * type function redex</span><span>
</span><span id="line-307"></span><span class="hs-comment">--      * data family redex</span><span>
</span><span id="line-308"></span><span class="hs-comment">--      * newtypes</span><span>
</span><span id="line-309"></span><span class="hs-comment">--</span><span>
</span><span id="line-310"></span><span class="hs-comment">-- Behaves like `topNormaliseType_maybe`, but instead of returning a</span><span>
</span><span id="line-311"></span><span class="hs-comment">-- coercion, it returns useful information for issuing pattern matching</span><span>
</span><span id="line-312"></span><span class="hs-comment">-- warnings. See Note [Type normalisation] for details.</span><span>
</span><span id="line-313"></span><span class="hs-comment">-- It also initially 'tcNormalise's the type with the bag of local constraints.</span><span>
</span><span id="line-314"></span><span class="hs-comment">--</span><span>
</span><span id="line-315"></span><span class="hs-comment">-- See 'TopNormaliseTypeResult' for the meaning of the return value.</span><span>
</span><span id="line-316"></span><span class="hs-comment">--</span><span>
</span><span id="line-317"></span><span class="hs-comment">-- NB: Normalisation can potentially change kinds, if the head of the type</span><span>
</span><span id="line-318"></span><span class="hs-comment">-- is a type family with a variable result kind. I (Richard E) can't think</span><span>
</span><span id="line-319"></span><span class="hs-comment">-- of a way to cause trouble here, though.</span><span>
</span><span id="line-320"></span><span id="pmTopNormaliseType"><span class="annot"><span class="annottext">pmTopNormaliseType :: TyState -&gt; Type -&gt; DsM TopNormaliseTypeResult
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmTopNormaliseType"><span class="hs-identifier hs-var hs-var">pmTopNormaliseType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TySt"><span class="hs-identifier hs-type">TySt</span></a></span><span> </span><span id="local-6989586621681147042"><span class="annot"><span class="annottext">Bag Id
</span><a href="#local-6989586621681147042"><span class="hs-identifier hs-var">inert</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681147041"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147041"><span class="hs-identifier hs-var">typ</span></a></span></span><span>
</span><span id="line-321"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681147040"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681147040"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM FamInstEnvs
</span><a href="GHC.HsToCore.Monad.html#dsGetFamInstEnvs"><span class="hs-identifier hs-var">dsGetFamInstEnvs</span></a></span><span>
</span><span id="line-322"></span><span>       </span><span class="hs-comment">-- Before proceeding, we chuck typ into the constraint solver, in case</span><span>
</span><span id="line-323"></span><span>       </span><span class="hs-comment">-- solving for given equalities may reduce typ some. See</span><span>
</span><span id="line-324"></span><span>       </span><span class="hs-comment">-- &quot;Wrinkle: local equalities&quot; in Note [Type normalisation].</span><span>
</span><span id="line-325"></span><span>       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Messages
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147038"><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681147038"><span class="hs-identifier hs-var">mb_typ'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Type -&gt; DsM (Messages, Maybe Type)
forall a. TcM a -&gt; DsM (Messages, Maybe a)
</span><a href="GHC.HsToCore.Monad.html#initTcDsForSolver"><span class="hs-identifier hs-var">initTcDsForSolver</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM Type -&gt; DsM (Messages, Maybe Type))
-&gt; TcM Type -&gt; DsM (Messages, Maybe Type)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Id -&gt; Type -&gt; TcM Type
</span><a href="GHC.Tc.Solver.html#tcNormalise"><span class="hs-identifier hs-var">tcNormalise</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Id
</span><a href="#local-6989586621681147042"><span class="hs-identifier hs-var">inert</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147041"><span class="hs-identifier hs-var">typ</span></a></span><span>
</span><span id="line-326"></span><span>       </span><span class="hs-comment">-- If tcNormalise didn't manage to simplify the type, continue anyway.</span><span>
</span><span id="line-327"></span><span>       </span><span class="hs-comment">-- We might be able to reduce type applications nonetheless!</span><span>
</span><span id="line-328"></span><span>       </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681147036"><span class="annot"><span class="annottext">typ' :: Type
</span><a href="#local-6989586621681147036"><span class="hs-identifier hs-var hs-var">typ'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Type -&gt; Type
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147041"><span class="hs-identifier hs-var">typ</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681147038"><span class="hs-identifier hs-var">mb_typ'</span></a></span><span>
</span><span id="line-329"></span><span>       </span><span class="hs-comment">-- Now we look with topNormaliseTypeX through type and data family</span><span>
</span><span id="line-330"></span><span>       </span><span class="hs-comment">-- applications and newtypes, which tcNormalise does not do.</span><span>
</span><span id="line-331"></span><span>       </span><span class="hs-comment">-- See also 'TopNormaliseTypeResult'.</span><span>
</span><span id="line-332"></span><span>       </span><span class="annot"><span class="annottext">TopNormaliseTypeResult -&gt; DsM TopNormaliseTypeResult
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(TopNormaliseTypeResult -&gt; DsM TopNormaliseTypeResult)
-&gt; TopNormaliseTypeResult -&gt; DsM TopNormaliseTypeResult
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">NormaliseStepper
  ([Type] -&gt; [Type],
   [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
-&gt; (([Type] -&gt; [Type],
     [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
    -&gt; ([Type] -&gt; [Type],
        [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
    -&gt; ([Type] -&gt; [Type],
        [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)]))
-&gt; Type
-&gt; Maybe
     (([Type] -&gt; [Type],
       [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)]),
      Type)
forall ev.
NormaliseStepper ev -&gt; (ev -&gt; ev -&gt; ev) -&gt; Type -&gt; Maybe (ev, Type)
</span><a href="GHC.Core.Coercion.html#topNormaliseTypeX"><span class="hs-identifier hs-var">topNormaliseTypeX</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FamInstEnvs
-&gt; NormaliseStepper
     ([Type] -&gt; [Type],
      [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
</span><a href="#local-6989586621681147033"><span class="hs-identifier hs-var">stepper</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681147040"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; [Type],
 [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
-&gt; ([Type] -&gt; [Type],
    [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
-&gt; ([Type] -&gt; [Type],
    [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
forall {b} {c} {b} {c} {a} {a}.
(b -&gt; c, b -&gt; c) -&gt; (a -&gt; b, a -&gt; b) -&gt; (a -&gt; c, a -&gt; c)
</span><a href="#local-6989586621681147032"><span class="hs-identifier hs-var">comb</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147036"><span class="hs-identifier hs-var">typ'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-333"></span><span>         </span><span class="annot"><span class="annottext">Maybe
  (([Type] -&gt; [Type],
    [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)]),
   Type)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-334"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Maybe Type
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621681147038"><span class="hs-identifier hs-var">mb_typ'</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TopNormaliseTypeResult
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#NoChange"><span class="hs-identifier hs-var">NoChange</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147041"><span class="hs-identifier hs-var">typ</span></a></span><span>
</span><span id="line-335"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TopNormaliseTypeResult
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#NormalisedByConstraints"><span class="hs-identifier hs-var">NormalisedByConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147036"><span class="hs-identifier hs-var">typ'</span></a></span><span>
</span><span id="line-336"></span><span>         </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681147031"><span class="annot"><span class="annottext">[Type] -&gt; [Type]
</span><a href="#local-6989586621681147031"><span class="hs-identifier hs-var">ty_f</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681147030"><span class="annot"><span class="annottext">[(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)]
</span><a href="#local-6989586621681147030"><span class="hs-identifier hs-var">tm_f</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147029"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147029"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [(Type, DataCon, Type)] -&gt; Type -&gt; TopNormaliseTypeResult
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#HadRedexes"><span class="hs-identifier hs-var">HadRedexes</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147028"><span class="hs-identifier hs-var">src_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681147027"><span class="hs-identifier hs-var">newtype_dcs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147026"><span class="hs-identifier hs-var">core_ty</span></a></span><span>
</span><span id="line-337"></span><span>           </span><span class="hs-keyword">where</span><span>
</span><span id="line-338"></span><span>             </span><span id="local-6989586621681147028"><span class="annot"><span class="annottext">src_ty :: Type
</span><a href="#local-6989586621681147028"><span class="hs-identifier hs-var hs-var">src_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; Type
</span><a href="#local-6989586621681147025"><span class="hs-identifier hs-var">eq_src_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147029"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147036"><span class="hs-identifier hs-var">typ'</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; [Type]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type]
</span><a href="#local-6989586621681147031"><span class="hs-identifier hs-var">ty_f</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147029"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-339"></span><span>             </span><span id="local-6989586621681147027"><span class="annot"><span class="annottext">newtype_dcs :: [(Type, DataCon, Type)]
</span><a href="#local-6989586621681147027"><span class="hs-identifier hs-var hs-var">newtype_dcs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)]
</span><a href="#local-6989586621681147030"><span class="hs-identifier hs-var">tm_f</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-340"></span><span>             </span><span id="local-6989586621681147026"><span class="annot"><span class="annottext">core_ty :: Type
</span><a href="#local-6989586621681147026"><span class="hs-identifier hs-var hs-var">core_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147029"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-341"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-342"></span><span>    </span><span class="hs-comment">-- Find the first type in the sequence of rewrites that is a data type,</span><span>
</span><span id="line-343"></span><span>    </span><span class="hs-comment">-- newtype, or a data family application (not the representation tycon!).</span><span>
</span><span id="line-344"></span><span>    </span><span class="hs-comment">-- This is the one that is equal (in source Haskell) to the initial type.</span><span>
</span><span id="line-345"></span><span>    </span><span class="hs-comment">-- If none is found in the list, then all of them are type family</span><span>
</span><span id="line-346"></span><span>    </span><span class="hs-comment">-- applications, so we simply return the last one, which is the *simplest*.</span><span>
</span><span id="line-347"></span><span>    </span><span class="annot"><a href="#local-6989586621681147025"><span class="hs-identifier hs-type">eq_src_ty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-348"></span><span>    </span><span id="local-6989586621681147025"><span class="annot"><span class="annottext">eq_src_ty :: Type -&gt; [Type] -&gt; Type
</span><a href="#local-6989586621681147025"><span class="hs-identifier hs-var hs-var">eq_src_ty</span></a></span></span><span> </span><span id="local-6989586621681147024"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147024"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681147023"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147023"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; (Type -&gt; Type) -&gt; Maybe Type -&gt; Type
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147024"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; [Type] -&gt; Maybe Type
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Maybe a
</span><a href="../../base/src/Data.Foldable.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="#local-6989586621681147020"><span class="hs-identifier hs-var">is_closed_or_data_family</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147023"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-349"></span><span>
</span><span id="line-350"></span><span>    </span><span class="annot"><a href="#local-6989586621681147020"><span class="hs-identifier hs-type">is_closed_or_data_family</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-351"></span><span>    </span><span id="local-6989586621681147020"><span class="annot"><span class="annottext">is_closed_or_data_family :: Type -&gt; Bool
</span><a href="#local-6989586621681147020"><span class="hs-identifier hs-var hs-var">is_closed_or_data_family</span></a></span></span><span> </span><span id="local-6989586621681147019"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147019"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmIsClosedType"><span class="hs-identifier hs-var">pmIsClosedType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147019"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isDataFamilyAppType"><span class="hs-identifier hs-var">isDataFamilyAppType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147019"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-352"></span><span>
</span><span id="line-353"></span><span>    </span><span class="hs-comment">-- For efficiency, represent both lists as difference lists.</span><span>
</span><span id="line-354"></span><span>    </span><span class="hs-comment">-- comb performs the concatenation, for both lists.</span><span>
</span><span id="line-355"></span><span>    </span><span id="local-6989586621681147032"><span class="annot"><span class="annottext">comb :: (b -&gt; c, b -&gt; c) -&gt; (a -&gt; b, a -&gt; b) -&gt; (a -&gt; c, a -&gt; c)
</span><a href="#local-6989586621681147032"><span class="hs-identifier hs-var hs-var">comb</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681147015"><span class="annot"><span class="annottext">b -&gt; c
</span><a href="#local-6989586621681147015"><span class="hs-identifier hs-var">tyf1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147014"><span class="annot"><span class="annottext">b -&gt; c
</span><a href="#local-6989586621681147014"><span class="hs-identifier hs-var">tmf1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681147013"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621681147013"><span class="hs-identifier hs-var">tyf2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147012"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621681147012"><span class="hs-identifier hs-var">tmf2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b -&gt; c
</span><a href="#local-6989586621681147015"><span class="hs-identifier hs-var">tyf1</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621681147013"><span class="hs-identifier hs-var">tyf2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b -&gt; c
</span><a href="#local-6989586621681147014"><span class="hs-identifier hs-var">tmf1</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621681147012"><span class="hs-identifier hs-var">tmf2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-356"></span><span>
</span><span id="line-357"></span><span>    </span><span id="local-6989586621681147033"><span class="annot"><span class="annottext">stepper :: FamInstEnvs
-&gt; NormaliseStepper
     ([Type] -&gt; [Type],
      [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
</span><a href="#local-6989586621681147033"><span class="hs-identifier hs-var hs-var">stepper</span></a></span></span><span> </span><span id="local-6989586621681147011"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681147011"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NormaliseStepper
  ([Type] -&gt; [Type],
   [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
</span><a href="#local-6989586621681147010"><span class="hs-identifier hs-var">newTypeStepper</span></a></span><span> </span><span class="annot"><span class="annottext">NormaliseStepper
  ([Type] -&gt; [Type],
   [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
-&gt; NormaliseStepper
     ([Type] -&gt; [Type],
      [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
-&gt; NormaliseStepper
     ([Type] -&gt; [Type],
      [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
forall ev.
NormaliseStepper ev -&gt; NormaliseStepper ev -&gt; NormaliseStepper ev
</span><a href="GHC.Core.Coercion.html#composeSteppers"><span class="hs-operator hs-var">`composeSteppers`</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
-&gt; NormaliseStepper
     ([Type] -&gt; [Type],
      [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
forall a.
FamInstEnvs -&gt; NormaliseStepper ([Type] -&gt; [Type], a -&gt; a)
</span><a href="#local-6989586621681147008"><span class="hs-identifier hs-var">tyFamStepper</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681147011"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-358"></span><span>
</span><span id="line-359"></span><span>    </span><span class="hs-comment">-- A 'NormaliseStepper' that unwraps newtypes, careful not to fall into</span><span>
</span><span id="line-360"></span><span>    </span><span class="hs-comment">-- a loop. If it would fall into a loop, it produces 'NS_Abort'.</span><span>
</span><span id="line-361"></span><span>    </span><span class="annot"><a href="#local-6989586621681147010"><span class="hs-identifier hs-type">newTypeStepper</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#NormaliseStepper"><span class="hs-identifier hs-type">NormaliseStepper</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-362"></span><span>    </span><span id="local-6989586621681147010"><span class="annot"><span class="annottext">newTypeStepper :: NormaliseStepper
  ([Type] -&gt; [Type],
   [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
</span><a href="#local-6989586621681147010"><span class="hs-identifier hs-var hs-var">newTypeStepper</span></a></span></span><span> </span><span id="local-6989586621681147007"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681147007"><span class="hs-identifier hs-var">rec_nts</span></a></span></span><span> </span><span id="local-6989586621681147006"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681147006"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681147005"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147005"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-363"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681147004"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147004"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681147003"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681147003"><span class="hs-identifier hs-var">_co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Maybe (Type, Coercion)
</span><a href="GHC.Core.Coercion.html#instNewTyCon_maybe"><span class="hs-identifier hs-var">instNewTyCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681147006"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147005"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-364"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681147001"><span class="annot"><span class="annottext">orig_ty :: Type
</span><a href="#local-6989586621681147001"><span class="hs-identifier hs-var hs-var">orig_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-var">TyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681147006"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681147005"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-365"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; TyCon -&gt; Maybe RecTcChecker
</span><a href="GHC.Core.TyCon.html#checkRecTc"><span class="hs-identifier hs-var">checkRecTc</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681147007"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681147006"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-366"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146998"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146998"><span class="hs-identifier hs-var">rec_nts'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146997"><span class="annot"><span class="annottext">tyf :: [Type] -&gt; [Type]
</span><a href="#local-6989586621681146997"><span class="hs-identifier hs-var hs-var">tyf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147001"><span class="hs-identifier hs-var">orig_ty</span></a></span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; [Type]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span>
</span><span id="line-367"></span><span>                               </span><span id="local-6989586621681146996"><span class="annot"><span class="annottext">tmf :: [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)]
</span><a href="#local-6989586621681146996"><span class="hs-identifier hs-var hs-var">tmf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147001"><span class="hs-identifier hs-var">orig_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; DataCon
</span><a href="GHC.Core.TyCon.html#tyConSingleDataCon"><span class="hs-identifier hs-var">tyConSingleDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681147006"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147004"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">)</span><span class="annot"><span class="annottext">(Type, DataCon, Type)
-&gt; [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span>
</span><span id="line-368"></span><span>                           </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">RecTcChecker
-&gt; Type
-&gt; ([Type] -&gt; [Type],
    [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
-&gt; NormaliseStepResult
     ([Type] -&gt; [Type],
      [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
forall ev. RecTcChecker -&gt; Type -&gt; ev -&gt; NormaliseStepResult ev
</span><a href="GHC.Core.Coercion.html#NS_Step"><span class="hs-identifier hs-var">NS_Step</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146998"><span class="hs-identifier hs-var">rec_nts'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681147004"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; [Type]
</span><a href="#local-6989586621681146997"><span class="hs-identifier hs-var">tyf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)]
</span><a href="#local-6989586621681146996"><span class="hs-identifier hs-var">tmf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-369"></span><span>          </span><span class="annot"><span class="annottext">Maybe RecTcChecker
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">NormaliseStepResult
  ([Type] -&gt; [Type],
   [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
forall ev. NormaliseStepResult ev
</span><a href="GHC.Core.Coercion.html#NS_Abort"><span class="hs-identifier hs-var">NS_Abort</span></a></span><span>
</span><span id="line-370"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-371"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NormaliseStepResult
  ([Type] -&gt; [Type],
   [(Type, DataCon, Type)] -&gt; [(Type, DataCon, Type)])
forall ev. NormaliseStepResult ev
</span><a href="GHC.Core.Coercion.html#NS_Done"><span class="hs-identifier hs-var">NS_Done</span></a></span><span>
</span><span id="line-372"></span><span>
</span><span id="line-373"></span><span>    </span><span id="local-6989586621681147734"><span class="annot"><a href="#local-6989586621681147008"><span class="hs-identifier hs-type">tyFamStepper</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInstEnvs"><span class="hs-identifier hs-type">FamInstEnvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#NormaliseStepper"><span class="hs-identifier hs-type">NormaliseStepper</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681147734"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681147734"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-374"></span><span>    </span><span id="local-6989586621681147008"><span class="annot"><span class="annottext">tyFamStepper :: forall a.
FamInstEnvs -&gt; NormaliseStepper ([Type] -&gt; [Type], a -&gt; a)
</span><a href="#local-6989586621681147008"><span class="hs-identifier hs-var hs-var">tyFamStepper</span></a></span></span><span> </span><span id="local-6989586621681146991"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146991"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681146990"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146990"><span class="hs-identifier hs-var">rec_nts</span></a></span></span><span> </span><span id="local-6989586621681146989"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146989"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681146988"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146988"><span class="hs-identifier hs-var">tys</span></a></span></span><span>  </span><span class="hs-comment">-- Try to step a type/data family</span><span>
</span><span id="line-375"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs -&gt; TyCon -&gt; [Type] -&gt; Maybe (Coercion, Type, Coercion)
</span><a href="GHC.Core.FamInstEnv.html#topReduceTyFamApp_maybe"><span class="hs-identifier hs-var">topReduceTyFamApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146991"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146989"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146988"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-376"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146986"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146986"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RecTcChecker
-&gt; Type
-&gt; ([Type] -&gt; [Type], a -&gt; a)
-&gt; NormaliseStepResult ([Type] -&gt; [Type], a -&gt; a)
forall ev. RecTcChecker -&gt; Type -&gt; ev -&gt; NormaliseStepResult ev
</span><a href="GHC.Core.Coercion.html#NS_Step"><span class="hs-identifier hs-var">NS_Step</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146990"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146986"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146986"><span class="hs-identifier hs-var">rhs</span></a></span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; [Type]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a -&gt; a
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-377"></span><span>          </span><span class="annot"><span class="annottext">Maybe (Coercion, Type, Coercion)
</span><span class="hs-identifier">_</span></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">NormaliseStepResult ([Type] -&gt; [Type], a -&gt; a)
forall ev. NormaliseStepResult ev
</span><a href="GHC.Core.Coercion.html#NS_Done"><span class="hs-identifier hs-var">NS_Done</span></a></span><span>
</span><span id="line-378"></span><span>
</span><span id="line-379"></span><span class="hs-comment">-- | Returns 'True' if the argument 'Type' is a fully saturated application of</span><span>
</span><span id="line-380"></span><span class="hs-comment">-- a closed type constructor.</span><span>
</span><span id="line-381"></span><span class="hs-comment">--</span><span>
</span><span id="line-382"></span><span class="hs-comment">-- Closed type constructors are those with a fixed right hand side, as</span><span>
</span><span id="line-383"></span><span class="hs-comment">-- opposed to e.g. associated types. These are of particular interest for</span><span>
</span><span id="line-384"></span><span class="hs-comment">-- pattern-match coverage checking, because GHC can exhaustively consider all</span><span>
</span><span id="line-385"></span><span class="hs-comment">-- possible forms that values of a closed type can take on.</span><span>
</span><span id="line-386"></span><span class="hs-comment">--</span><span>
</span><span id="line-387"></span><span class="hs-comment">-- Note that this function is intended to be used to check types of value-level</span><span>
</span><span id="line-388"></span><span class="hs-comment">-- patterns, so as a consequence, the 'Type' supplied as an argument to this</span><span>
</span><span id="line-389"></span><span class="hs-comment">-- function should be of kind @Type@.</span><span>
</span><span id="line-390"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#pmIsClosedType"><span class="hs-identifier hs-type">pmIsClosedType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-391"></span><span id="pmIsClosedType"><span class="annot"><span class="annottext">pmIsClosedType :: Type -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmIsClosedType"><span class="hs-identifier hs-var hs-var">pmIsClosedType</span></a></span></span><span> </span><span id="local-6989586621681146985"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146985"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-392"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146985"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-393"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146983"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146983"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146982"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146982"><span class="hs-identifier hs-var">ty_args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-394"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="#local-6989586621681146981"><span class="hs-identifier hs-var">is_algebraic_like</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146983"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isFamilyTyCon"><span class="hs-identifier hs-var">isFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146983"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-395"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">ty_args</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">lengthIs</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">tyConArity</span><span> </span><span class="hs-identifier">tc</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">ty</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">True</span><span>
</span><span id="line-396"></span><span>      </span><span id="local-6989586621681146973"><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621681146973"><span class="hs-identifier hs-var">_other</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-397"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-398"></span><span>    </span><span class="hs-comment">-- This returns True for TyCons which /act like/ algebraic types.</span><span>
</span><span id="line-399"></span><span>    </span><span class="hs-comment">-- (See &quot;Type#type_classification&quot; for what an algebraic type is.)</span><span>
</span><span id="line-400"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-401"></span><span>    </span><span class="hs-comment">-- This is qualified with \&quot;like\&quot; because of a particular special</span><span>
</span><span id="line-402"></span><span>    </span><span class="hs-comment">-- case: TYPE (the underlyind kind behind Type, among others). TYPE</span><span>
</span><span id="line-403"></span><span>    </span><span class="hs-comment">-- is conceptually a datatype (and thus algebraic), but in practice it is</span><span>
</span><span id="line-404"></span><span>    </span><span class="hs-comment">-- a primitive builtin type, so we must check for it specially.</span><span>
</span><span id="line-405"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-406"></span><span>    </span><span class="hs-comment">-- NB: it makes sense to think of TYPE as a closed type in a value-level,</span><span>
</span><span id="line-407"></span><span>    </span><span class="hs-comment">-- pattern-matching context. However, at the kind level, TYPE is certainly</span><span>
</span><span id="line-408"></span><span>    </span><span class="hs-comment">-- not closed! Since this function is specifically tailored towards pattern</span><span>
</span><span id="line-409"></span><span>    </span><span class="hs-comment">-- matching, however, it's OK to label TYPE as closed.</span><span>
</span><span id="line-410"></span><span>    </span><span class="annot"><a href="#local-6989586621681146981"><span class="hs-identifier hs-type">is_algebraic_like</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-411"></span><span>    </span><span id="local-6989586621681146981"><span class="annot"><span class="annottext">is_algebraic_like :: TyCon -&gt; Bool
</span><a href="#local-6989586621681146981"><span class="hs-identifier hs-var hs-var">is_algebraic_like</span></a></span></span><span> </span><span id="local-6989586621681146972"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146972"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isAlgTyCon"><span class="hs-identifier hs-var">isAlgTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146972"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146972"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#tYPETyCon"><span class="hs-identifier hs-var">tYPETyCon</span></a></span><span>
</span><span id="line-412"></span><span>
</span><span id="line-413"></span><span class="hs-comment">{- Note [Type normalisation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Constructs like -XEmptyCase or a previous unsuccessful pattern match on a data
constructor place a non-void constraint on the matched thing. This means that it
boils down to checking whether the type of the scrutinee is inhabited. Function
pmTopNormaliseType gets rid of the outermost type function/data family redex and
newtypes, in search of an algebraic type constructor, which is easier to check
for inhabitation.

It returns 3 results instead of one, because there are 2 subtle points:
1. Newtypes are isomorphic to the underlying type in core but not in the source
   language,
2. The representational data family tycon is used internally but should not be
   shown to the user

Hence, if pmTopNormaliseType env ty_cs ty = Just (src_ty, dcs, core_ty),
then
  (a) src_ty is the rewritten type which we can show to the user. That is, the
      type we get if we rewrite type families but not data families or
      newtypes.
  (b) dcs is the list of newtype constructors &quot;skipped&quot;, every time we normalise
      a newtype to its core representation, we keep track of the source data
      constructor. For convenience, we also track the type we unwrap and the
      type of its field. Example: @Down 42@ =&gt; @[(Down @Int, Down, Int)]
  (c) core_ty is the rewritten type. That is,
        pmTopNormaliseType env ty_cs ty = Just (src_ty, dcs, core_ty)
      implies
        topNormaliseType_maybe env ty = Just (co, core_ty)
      for some coercion co.

To see how all cases come into play, consider the following example:

  data family T a :: *
  data instance T Int = T1 | T2 Bool
  -- Which gives rise to FC:
  --   data T a
  --   data R:TInt = T1 | T2 Bool
  --   axiom ax_ti : T Int ~R R:TInt

  newtype G1 = MkG1 (T Int)
  newtype G2 = MkG2 G1

  type instance F Int  = F Char
  type instance F Char = G2

In this case pmTopNormaliseType env ty_cs (F Int) results in

  Just (G2, [(G2,MkG2,G1),(G1,MkG1,T Int)], R:TInt)

Which means that in source Haskell:
  - G2 is equivalent to F Int (in contrast, G1 isn't).
  - if (x : R:TInt) then (MkG2 (MkG1 x) : F Int).

-----
-- Wrinkle: Local equalities
-----

Given the following type family:

  type family F a
  type instance F Int = Void

Should the following program (from #14813) be considered exhaustive?

  f :: (i ~ Int) =&gt; F i -&gt; a
  f x = case x of {}

You might think &quot;of course, since `x` is obviously of type Void&quot;. But the
idType of `x` is technically F i, not Void, so if we pass F i to
inhabitationCandidates, we'll mistakenly conclude that `f` is non-exhaustive.
In order to avoid this pitfall, we need to normalise the type passed to
pmTopNormaliseType, using the constraint solver to solve for any local
equalities (such as i ~ Int) that may be in scope.
-}</span><span>
</span><span id="line-487"></span><span>
</span><span id="line-488"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-489"></span><span class="hs-comment">-- * Type oracle</span><span>
</span><span id="line-490"></span><span>
</span><span id="line-491"></span><span class="hs-comment">-- | Allocates a fresh 'EvVar' name for 'PredTy's.</span><span>
</span><span id="line-492"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#nameTyCt"><span class="hs-identifier hs-type">nameTyCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span>
</span><span id="line-493"></span><span id="nameTyCt"><span class="annot"><span class="annottext">nameTyCt :: Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#nameTyCt"><span class="hs-identifier hs-var hs-var">nameTyCt</span></a></span></span><span> </span><span id="local-6989586621681146968"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146968"><span class="hs-identifier hs-var">pred_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-494"></span><span>  </span><span id="local-6989586621681146967"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681146967"><span class="hs-identifier hs-var">unique</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) Unique
forall (m :: * -&gt; *). MonadUnique m =&gt; m Unique
</span><a href="GHC.Types.Unique.Supply.html#getUniqueM"><span class="hs-identifier hs-var">getUniqueM</span></a></span><span>
</span><span id="line-495"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146964"><span class="annot"><span class="annottext">occname :: OccName
</span><a href="#local-6989586621681146964"><span class="hs-identifier hs-var hs-var">occname</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkVarOccFS"><span class="hs-identifier hs-var">mkVarOccFS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;pm_&quot;</span></span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="annot"><span class="annottext">Unique -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681146967"><span class="hs-identifier hs-var">unique</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-496"></span><span>      </span><span id="local-6989586621681146962"><span class="annot"><span class="annottext">idname :: Name
</span><a href="#local-6989586621681146962"><span class="hs-identifier hs-var hs-var">idname</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; SrcSpan -&gt; Name
</span><a href="GHC.Types.Name.html#mkInternalName"><span class="hs-identifier hs-var">mkInternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681146967"><span class="hs-identifier hs-var">unique</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681146964"><span class="hs-identifier hs-var">occname</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="GHC.Types.SrcLoc.html#noSrcSpan"><span class="hs-identifier hs-var">noSrcSpan</span></a></span><span>
</span><span id="line-497"></span><span>  </span><span class="annot"><span class="annottext">Id -&gt; DsM Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; Type -&gt; Id
</span><a href="GHC.Types.Id.html#mkLocalIdOrCoVar"><span class="hs-identifier hs-var">mkLocalIdOrCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681146962"><span class="hs-identifier hs-var">idname</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146968"><span class="hs-identifier hs-var">pred_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-498"></span><span>
</span><span id="line-499"></span><span class="hs-comment">-- | Add some extra type constraints to the 'TyState'; return 'Nothing' if we</span><span>
</span><span id="line-500"></span><span class="hs-comment">-- find a contradiction (e.g. @Int ~ Bool@).</span><span>
</span><span id="line-501"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tyOracle"><span class="hs-identifier hs-type">tyOracle</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TyState"><span class="hs-identifier hs-type">TyState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TyState"><span class="hs-identifier hs-type">TyState</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-502"></span><span id="tyOracle"><span class="annot"><span class="annottext">tyOracle :: TyState -&gt; Bag Type -&gt; DsM (Maybe TyState)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tyOracle"><span class="hs-identifier hs-var hs-var">tyOracle</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TySt"><span class="hs-identifier hs-type">TySt</span></a></span><span> </span><span id="local-6989586621681146960"><span class="annot"><span class="annottext">Bag Id
</span><a href="#local-6989586621681146960"><span class="hs-identifier hs-var">inert</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681146959"><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146959"><span class="hs-identifier hs-var">cts</span></a></span></span><span>
</span><span id="line-503"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681146958"><span class="annot"><span class="annottext">Bag Id
</span><a href="#local-6989586621681146958"><span class="hs-identifier hs-var">evs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; DsM Id)
-&gt; Bag Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) (Bag Id)
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#nameTyCt"><span class="hs-identifier hs-var">nameTyCt</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146959"><span class="hs-identifier hs-var">cts</span></a></span><span>
</span><span id="line-504"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146956"><span class="annot"><span class="annottext">new_inert :: Bag Id
</span><a href="#local-6989586621681146956"><span class="hs-identifier hs-var hs-var">new_inert</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Id
</span><a href="#local-6989586621681146960"><span class="hs-identifier hs-var">inert</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Id -&gt; Bag Id -&gt; Bag Id
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Id
</span><a href="#local-6989586621681146958"><span class="hs-identifier hs-var">evs</span></a></span><span>
</span><span id="line-505"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-var">tracePm</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tyOracle&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146959"><span class="hs-identifier hs-var">cts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-506"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681146954"><span class="annot"><span class="annottext">WarningMessages
</span><a href="#local-6989586621681146954"><span class="hs-identifier hs-var">_warns</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146953"><span class="annot"><span class="annottext">WarningMessages
</span><a href="#local-6989586621681146953"><span class="hs-identifier hs-var">errs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146952"><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681146952"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Bool -&gt; DsM (Messages, Maybe Bool)
forall a. TcM a -&gt; DsM (Messages, Maybe a)
</span><a href="GHC.HsToCore.Monad.html#initTcDsForSolver"><span class="hs-identifier hs-var">initTcDsForSolver</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM Bool -&gt; DsM (Messages, Maybe Bool))
-&gt; TcM Bool -&gt; DsM (Messages, Maybe Bool)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Id -&gt; TcM Bool
</span><a href="GHC.Tc.Solver.html#tcCheckSatisfiability"><span class="hs-identifier hs-var">tcCheckSatisfiability</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Id
</span><a href="#local-6989586621681146956"><span class="hs-identifier hs-var">new_inert</span></a></span><span>
</span><span id="line-507"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Bool
</span><a href="#local-6989586621681146952"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-508"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TyState -&gt; DsM (Maybe TyState)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyState -&gt; Maybe TyState
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag Id -&gt; TyState
</span><a href="GHC.HsToCore.PmCheck.Types.html#TySt"><span class="hs-identifier hs-var">TySt</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Id
</span><a href="#local-6989586621681146956"><span class="hs-identifier hs-var">new_inert</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-509"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TyState -&gt; DsM (Maybe TyState)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TyState
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-510"></span><span>            </span><span class="annot"><span class="annottext">Maybe Bool
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM (Maybe TyState)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tyOracle&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WarningMessages -&gt; [SDoc]
</span><a href="GHC.Utils.Error.html#pprErrMsgBagWithLoc"><span class="hs-identifier hs-var">pprErrMsgBagWithLoc</span></a></span><span> </span><span class="annot"><span class="annottext">WarningMessages
</span><a href="#local-6989586621681146953"><span class="hs-identifier hs-var">errs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-511"></span><span>
</span><span id="line-512"></span><span class="hs-comment">-- | A 'SatisfiabilityCheck' based on new type-level constraints.</span><span>
</span><span id="line-513"></span><span class="hs-comment">-- Returns a new 'Delta' if the new constraints are compatible with existing</span><span>
</span><span id="line-514"></span><span class="hs-comment">-- ones. Doesn't bother calling out to the type oracle if the bag of new type</span><span>
</span><span id="line-515"></span><span class="hs-comment">-- constraints was empty. Will only recheck 'PossibleMatches' in the term oracle</span><span>
</span><span id="line-516"></span><span class="hs-comment">-- for emptiness if the first argument is 'True'.</span><span>
</span><span id="line-517"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tyIsSatisfiable"><span class="hs-identifier hs-type">tyIsSatisfiable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SatisfiabilityCheck"><span class="hs-identifier hs-type">SatisfiabilityCheck</span></a></span><span>
</span><span id="line-518"></span><span id="tyIsSatisfiable"><span class="annot"><span class="annottext">tyIsSatisfiable :: Bool -&gt; Bag Type -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tyIsSatisfiable"><span class="hs-identifier hs-var hs-var">tyIsSatisfiable</span></a></span></span><span> </span><span id="local-6989586621681146948"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681146948"><span class="hs-identifier hs-var">recheck_complete_sets</span></a></span></span><span> </span><span id="local-6989586621681146947"><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146947"><span class="hs-identifier hs-var">new_ty_cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-var">SC</span></a></span><span> </span><span class="annot"><span class="annottext">((Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck)
-&gt; (Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681146946"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146946"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-519"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bag Type -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146947"><span class="hs-identifier hs-var">new_ty_cs</span></a></span><span>
</span><span id="line-520"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe Delta -&gt; DsM (Maybe Delta)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; Maybe Delta
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146946"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-521"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">TyState -&gt; Bag Type -&gt; DsM (Maybe TyState)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tyOracle"><span class="hs-identifier hs-var">tyOracle</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; TyState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_ty_st"><span class="hs-identifier hs-var hs-var">delta_ty_st</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146946"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146947"><span class="hs-identifier hs-var">new_ty_cs</span></a></span><span> </span><span class="annot"><span class="annottext">DsM (Maybe TyState)
-&gt; (Maybe TyState -&gt; DsM (Maybe Delta)) -&gt; DsM (Maybe Delta)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-glyph">case</span><span>
</span><span id="line-522"></span><span>      </span><span class="annot"><span class="annottext">Maybe TyState
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Delta -&gt; DsM (Maybe Delta)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Delta
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-523"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146943"><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146943"><span class="hs-identifier hs-var">ty_st'</span></a></span></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-524"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146942"><span class="annot"><span class="annottext">delta' :: Delta
</span><a href="#local-6989586621681146942"><span class="hs-identifier hs-var hs-var">delta'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146946"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_ty_st :: TyState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_ty_st"><span class="hs-identifier hs-var">delta_ty_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146943"><span class="hs-identifier hs-var">ty_st'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-525"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681146948"><span class="hs-identifier hs-var">recheck_complete_sets</span></a></span><span>
</span><span id="line-526"></span><span>          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ensureAllPossibleMatchesInhabited"><span class="hs-identifier hs-var">ensureAllPossibleMatchesInhabited</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146942"><span class="hs-identifier hs-var">delta'</span></a></span><span>
</span><span id="line-527"></span><span>          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe Delta -&gt; DsM (Maybe Delta)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; Maybe Delta
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146942"><span class="hs-identifier hs-var">delta'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-528"></span><span>
</span><span id="line-529"></span><span>
</span><span id="line-530"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
              DIdEnv with sharing
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-535"></span><span>
</span><span id="line-536"></span><span>
</span><span id="line-537"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                 TmState
          What we know about terms
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-543"></span><span>
</span><span id="line-544"></span><span class="hs-comment">{- Note [The Pos/Neg invariant]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Invariant applying to each VarInfo: Whenever we have @(C, [y,z])@ in 'vi_pos',
any entry in 'vi_neg' must be incomparable to C (return Nothing) according to
'eqPmAltCons'. Those entries that are comparable either lead to a refutation
or are redundant. Examples:
* @x ~ Just y@, @x /~ [Just]@. 'eqPmAltCon' returns @Equal@, so refute.
* @x ~ Nothing@, @x /~ [Just]@. 'eqPmAltCon' returns @Disjoint@, so negative
  info is redundant and should be discarded.
* @x ~ I# y@, @x /~ [4,2]@. 'eqPmAltCon' returns @PossiblyOverlap@, so orthogal.
  We keep this info in order to be able to refute a redundant match on i.e. 4
  later on.

This carries over to pattern synonyms and overloaded literals. Say, we have
    pattern Just42 = Just 42
    case Just42 of x
      Nothing -&gt; ()
      Just _  -&gt; ()
Even though we had a solution for the value abstraction called x here in form
of a PatSynCon (Just42,[]), this solution is incomparable to both Nothing and
Just. Hence we retain the info in vi_neg, which eventually allows us to detect
the complete pattern match.

The Pos/Neg invariant extends to vi_cache, which stores essentially positive
information. We make sure that vi_neg and vi_cache never overlap. This isn't
strictly necessary since vi_cache is just a cache, so doesn't need to be
accurate: Every suggestion of a possible ConLike from vi_cache might be
refutable by the type oracle anyway. But it helps to maintain sanity while
debugging traces.

Note [Why record both positive and negative info?]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You might think that knowing positive info (like x ~ Just y) would render
negative info irrelevant, but not so because of pattern synonyms.  E.g we might
know that x cannot match (Foo 4), where pattern Foo p = Just p

Also overloaded literals themselves behave like pattern synonyms. E.g if
postively we know that (x ~ I# y), we might also negatively want to record that
x does not match 45 f 45       = e2 f (I# 22#) = e3 f 45       = e4  --
Overlapped

Note [TmState invariants]
~~~~~~~~~~~~~~~~~~~~~~~~~
The term oracle state is never obviously (i.e., without consulting the type
oracle) contradictory. This implies a few invariants:
* Whenever vi_pos overlaps with vi_neg according to 'eqPmAltCon', we refute.
  This is implied by the Note [Pos/Neg invariant].
* Whenever vi_neg subsumes a COMPLETE set, we refute. We consult vi_cache to
  detect this, but we could just compare whole COMPLETE sets to vi_neg every
  time, if it weren't for performance.

Maintaining these invariants in 'addVarCt' (the core of the term oracle) and
'addNotConCt' is subtle.
* Merging VarInfos. Example: Add the fact @x ~ y@ (see 'equate').
  - (COMPLETE) If we had @x /~ True@ and @y /~ False@, then we get
    @x /~ [True,False]@. This is vacuous by matter of comparing to the built-in
    COMPLETE set, so should refute.
  - (Pos/Neg) If we had @x /~ True@ and @y ~ True@, we have to refute.
* Adding positive information. Example: Add the fact @x ~ K ys@ (see 'addConCt')
  - (Neg) If we had @x /~ K@, refute.
  - (Pos) If we had @x ~ K2@, and that contradicts the new solution according to
    'eqPmAltCon' (ex. K2 is [] and K is (:)), then refute.
  - (Refine) If we had @x /~ K zs@, unify each y with each z in turn.
* Adding negative information. Example: Add the fact @x /~ Nothing@ (see 'addNotConCt')
  - (Refut) If we have @x ~ K ys@, refute.
  - (COMPLETE) If K=Nothing and we had @x /~ Just@, then we get
    @x /~ [Just,Nothing]@. This is vacuous by matter of comparing to the built-in
    COMPLETE set, so should refute.

Note that merging VarInfo in equate can be done by calling out to 'addConCt' and
'addNotConCt' for each of the facts individually.

Note [Representation of Strings in TmState]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Instead of treating regular String literals as a PmLits, we treat it as a list
of characters in the oracle for better overlap reasoning. The following example
shows why:

  f :: String -&gt; ()
  f ('f':_) = ()
  f &quot;foo&quot;   = ()
  f _       = ()

The second case is redundant, and we like to warn about it. Therefore either
the oracle will have to do some smart conversion between the list and literal
representation or treat is as the list it really is at runtime.

The &quot;smart conversion&quot; has the advantage of leveraging the more compact literal
representation wherever possible, but is really nasty to get right with negative
equalities: Just think of how to encode @x /= &quot;foo&quot;@.
The &quot;list&quot; option is far simpler, but incurs some overhead in representation and
warning messages (which can be alleviated by someone with enough dedication).
-}</span><span>
</span><span id="line-637"></span><span>
</span><span id="line-638"></span><span class="hs-comment">-- | A 'SatisfiabilityCheck' based on new term-level constraints.</span><span>
</span><span id="line-639"></span><span class="hs-comment">-- Returns a new 'Delta' if the new constraints are compatible with existing</span><span>
</span><span id="line-640"></span><span class="hs-comment">-- ones.</span><span>
</span><span id="line-641"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tmIsSatisfiable"><span class="hs-identifier hs-type">tmIsSatisfiable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCt"><span class="hs-identifier hs-type">TmCt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SatisfiabilityCheck"><span class="hs-identifier hs-type">SatisfiabilityCheck</span></a></span><span>
</span><span id="line-642"></span><span id="tmIsSatisfiable"><span class="annot"><span class="annottext">tmIsSatisfiable :: Bag TmCt -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tmIsSatisfiable"><span class="hs-identifier hs-var hs-var">tmIsSatisfiable</span></a></span></span><span> </span><span id="local-6989586621681146940"><span class="annot"><span class="annottext">Bag TmCt
</span><a href="#local-6989586621681146940"><span class="hs-identifier hs-var">new_tm_cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-var">SC</span></a></span><span> </span><span class="annot"><span class="annottext">((Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck)
-&gt; (Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681146939"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146939"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM Delta -&gt; DsM (Maybe Delta)
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(MaybeT DsM Delta -&gt; DsM (Maybe Delta))
-&gt; MaybeT DsM Delta -&gt; DsM (Maybe Delta)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; TmCt -&gt; MaybeT DsM Delta)
-&gt; Delta -&gt; Bag TmCt -&gt; MaybeT DsM Delta
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; TmCt -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addTmCt"><span class="hs-identifier hs-var">addTmCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146939"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Bag TmCt
</span><a href="#local-6989586621681146940"><span class="hs-identifier hs-var">new_tm_cs</span></a></span><span>
</span><span id="line-643"></span><span>
</span><span id="line-644"></span><span class="hs-comment">-----------------------</span><span>
</span><span id="line-645"></span><span class="hs-comment">-- * Looking up VarInfo</span><span>
</span><span id="line-646"></span><span>
</span><span id="line-647"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#emptyVarInfo"><span class="hs-identifier hs-type">emptyVarInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VarInfo"><span class="hs-identifier hs-type">VarInfo</span></a></span><span>
</span><span id="line-648"></span><span id="emptyVarInfo"><span class="annot"><span class="annottext">emptyVarInfo :: Id -&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#emptyVarInfo"><span class="hs-identifier hs-var hs-var">emptyVarInfo</span></a></span></span><span> </span><span id="local-6989586621681146935"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146935"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
-&gt; [(PmAltCon, [Id], [Id])]
-&gt; PmAltConSet
-&gt; PossibleMatches
-&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Types.html#VI"><span class="hs-identifier hs-var">VI</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146935"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="GHC.HsToCore.PmCheck.Types.html#emptyPmAltConSet"><span class="hs-identifier hs-var">emptyPmAltConSet</span></a></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#NoPM"><span class="hs-identifier hs-var">NoPM</span></a></span><span>
</span><span id="line-649"></span><span>
</span><span id="line-650"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupVarInfo"><span class="hs-identifier hs-type">lookupVarInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmState"><span class="hs-identifier hs-type">TmState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VarInfo"><span class="hs-identifier hs-type">VarInfo</span></a></span><span>
</span><span id="line-651"></span><span class="hs-comment">-- (lookupVarInfo tms x) tells what we know about 'x'</span><span>
</span><span id="line-652"></span><span id="lookupVarInfo"><span class="annot"><span class="annottext">lookupVarInfo :: TmState -&gt; Id -&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupVarInfo"><span class="hs-identifier hs-var hs-var">lookupVarInfo</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span> </span><span id="local-6989586621681146929"><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146929"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681146928"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146928"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; Maybe VarInfo -&gt; VarInfo
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#emptyVarInfo"><span class="hs-identifier hs-var">emptyVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146928"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; Maybe VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.HsToCore.PmCheck.Types.html#lookupSDIE"><span class="hs-identifier hs-var">lookupSDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146929"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146928"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-653"></span><span>
</span><span id="line-654"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#initPossibleMatches"><span class="hs-identifier hs-type">initPossibleMatches</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TyState"><span class="hs-identifier hs-type">TyState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VarInfo"><span class="hs-identifier hs-type">VarInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VarInfo"><span class="hs-identifier hs-type">VarInfo</span></a></span><span>
</span><span id="line-655"></span><span id="initPossibleMatches"><span class="annot"><span class="annottext">initPossibleMatches :: TyState -&gt; VarInfo -&gt; DsM VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#initPossibleMatches"><span class="hs-identifier hs-var hs-var">initPossibleMatches</span></a></span></span><span> </span><span id="local-6989586621681146925"><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146925"><span class="hs-identifier hs-var">ty_st</span></a></span></span><span> </span><span id="local-6989586621681146924"><span class="annot"><span class="annottext">vi :: VarInfo
</span><a href="#local-6989586621681146924"><span class="hs-identifier hs-var">vi</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VI"><span class="hs-identifier hs-type">VI</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">vi_ty :: VarInfo -&gt; Type
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_ty"><span class="hs-identifier hs-var">vi_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146922"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146922"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">vi_cache :: VarInfo -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_cache"><span class="hs-identifier hs-var">vi_cache</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#NoPM"><span class="hs-identifier hs-var">NoPM</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-656"></span><span>  </span><span class="hs-comment">-- New evidence might lead to refined info on ty, in turn leading to discovery</span><span>
</span><span id="line-657"></span><span>  </span><span class="hs-comment">-- of a COMPLETE set.</span><span>
</span><span id="line-658"></span><span>  </span><span id="local-6989586621681146920"><span class="annot"><span class="annottext">TopNormaliseTypeResult
</span><a href="#local-6989586621681146920"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyState -&gt; Type -&gt; DsM TopNormaliseTypeResult
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmTopNormaliseType"><span class="hs-identifier hs-var">pmTopNormaliseType</span></a></span><span> </span><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146925"><span class="hs-identifier hs-var">ty_st</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146922"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-659"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146919"><span class="annot"><span class="annottext">ty' :: Type
</span><a href="#local-6989586621681146919"><span class="hs-identifier hs-var hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopNormaliseTypeResult -&gt; Type
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#normalisedSourceType"><span class="hs-identifier hs-var">normalisedSourceType</span></a></span><span> </span><span class="annot"><span class="annottext">TopNormaliseTypeResult
</span><a href="#local-6989586621681146920"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-660"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146919"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-661"></span><span>    </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; DsM VarInfo
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146924"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">vi_ty :: Type
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_ty"><span class="hs-identifier hs-var">vi_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146919"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-662"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146918"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146918"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-663"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146918"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#tYPETyCon"><span class="hs-identifier hs-var">tYPETyCon</span></a></span><span>
</span><span id="line-664"></span><span>      </span><span class="hs-comment">-- TYPE acts like an empty data type on the term-level (#14086), but</span><span>
</span><span id="line-665"></span><span>      </span><span class="hs-comment">-- it is a PrimTyCon, so tyConDataCons_maybe returns Nothing. Hence a</span><span>
</span><span id="line-666"></span><span>      </span><span class="hs-comment">-- special case.</span><span>
</span><span id="line-667"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; DsM VarInfo
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146924"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">vi_ty :: Type
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_ty"><span class="hs-identifier hs-var">vi_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146919"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">vi_cache :: PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_cache"><span class="hs-identifier hs-var">vi_cache</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NonEmpty ConLikeSet -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#PM"><span class="hs-identifier hs-var">PM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLikeSet -&gt; NonEmpty ConLikeSet
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">ConLikeSet
forall a. UniqDSet a
</span><a href="GHC.Types.Unique.DSet.html#emptyUniqDSet"><span class="hs-identifier hs-var">emptyUniqDSet</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-668"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146916"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146916"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146915"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146915"><span class="hs-identifier hs-var">tc_args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-669"></span><span>      </span><span class="hs-comment">-- See Note [COMPLETE sets on data families]</span><span>
</span><span id="line-670"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681146914"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146914"><span class="hs-identifier hs-var">tc_rep</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146913"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146913"><span class="hs-identifier hs-var">tc_fam</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.TyCon.html#tyConFamInst_maybe"><span class="hs-identifier hs-var">tyConFamInst_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146916"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-671"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146911"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146911"><span class="hs-identifier hs-var">tc_fam</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(TyCon, TyCon) -&gt; IOEnv (Env DsGblEnv DsLclEnv) (TyCon, TyCon)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146916"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146911"><span class="hs-identifier hs-var">tc_fam</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-672"></span><span>        </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-673"></span><span>          </span><span id="local-6989586621681146910"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146910"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM FamInstEnvs
</span><a href="GHC.HsToCore.Monad.html#dsGetFamInstEnvs"><span class="hs-identifier hs-var">dsGetFamInstEnvs</span></a></span><span>
</span><span id="line-674"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146909"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146909"><span class="hs-identifier hs-var">tc_rep</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146908"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146908"><span class="hs-identifier hs-var">_tc_rep_args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146907"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681146907"><span class="hs-identifier hs-var">_co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs -&gt; TyCon -&gt; [Type] -&gt; (TyCon, [Type], Coercion)
</span><a href="GHC.Tc.Instance.Family.html#tcLookupDataFamInst"><span class="hs-identifier hs-var">tcLookupDataFamInst</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146910"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146916"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146915"><span class="hs-identifier hs-var">tc_args</span></a></span><span>
</span><span id="line-675"></span><span>          </span><span class="annot"><span class="annottext">(TyCon, TyCon) -&gt; IOEnv (Env DsGblEnv DsLclEnv) (TyCon, TyCon)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146909"><span class="hs-identifier hs-var">tc_rep</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146916"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-676"></span><span>      </span><span class="hs-comment">-- Note that the common case here is tc_rep == tc_fam</span><span>
</span><span id="line-677"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146904"><span class="annot"><span class="annottext">mb_rdcs :: Maybe [ConLike]
</span><a href="#local-6989586621681146904"><span class="hs-identifier hs-var hs-var">mb_rdcs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DataCon -&gt; ConLike) -&gt; [DataCon] -&gt; [ConLike]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; ConLike
</span><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-var">RealDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">([DataCon] -&gt; [ConLike]) -&gt; Maybe [DataCon] -&gt; Maybe [ConLike]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons_maybe"><span class="hs-identifier hs-var">tyConDataCons_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146914"><span class="hs-identifier hs-var">tc_rep</span></a></span><span>
</span><span id="line-678"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146902"><span class="annot"><span class="annottext">rdcs :: [[ConLike]]
</span><a href="#local-6989586621681146902"><span class="hs-identifier hs-var hs-var">rdcs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe [ConLike] -&gt; [[ConLike]]
forall a. Maybe a -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#maybeToList"><span class="hs-identifier hs-var">maybeToList</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe [ConLike]
</span><a href="#local-6989586621681146904"><span class="hs-identifier hs-var">mb_rdcs</span></a></span><span>
</span><span id="line-679"></span><span>      </span><span class="hs-comment">-- NB: tc_fam, because COMPLETE sets are associated with the parent data</span><span>
</span><span id="line-680"></span><span>      </span><span class="hs-comment">-- family TyCon</span><span>
</span><span id="line-681"></span><span>      </span><span id="local-6989586621681146900"><span class="annot"><span class="annottext">[CompleteMatch]
</span><a href="#local-6989586621681146900"><span class="hs-identifier hs-var">pragmas</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; DsM [CompleteMatch]
</span><a href="GHC.HsToCore.Monad.html#dsGetCompleteMatches"><span class="hs-identifier hs-var">dsGetCompleteMatches</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146913"><span class="hs-identifier hs-var">tc_fam</span></a></span><span>
</span><span id="line-682"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146896"><span class="annot"><span class="annottext">fams :: CompleteMatch -&gt; IOEnv (Env DsGblEnv DsLclEnv) [ConLike]
</span><a href="#local-6989586621681146896"><span class="hs-identifier hs-var hs-var">fams</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; IOEnv (Env DsGblEnv DsLclEnv) ConLike)
-&gt; [Name] -&gt; IOEnv (Env DsGblEnv DsLclEnv) [ConLike]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; IOEnv (Env DsGblEnv DsLclEnv) ConLike
</span><a href="GHC.HsToCore.Monad.html#dsLookupConLike"><span class="hs-identifier hs-var">dsLookupConLike</span></a></span><span> </span><span class="annot"><span class="annottext">([Name] -&gt; IOEnv (Env DsGblEnv DsLclEnv) [ConLike])
-&gt; (CompleteMatch -&gt; [Name])
-&gt; CompleteMatch
-&gt; IOEnv (Env DsGblEnv DsLclEnv) [ConLike]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CompleteMatch -&gt; [Name]
</span><a href="GHC.Driver.Types.html#completeMatchConLikes"><span class="hs-identifier hs-var hs-var">completeMatchConLikes</span></a></span><span>
</span><span id="line-683"></span><span>      </span><span id="local-6989586621681146894"><span class="annot"><span class="annottext">[[ConLike]]
</span><a href="#local-6989586621681146894"><span class="hs-identifier hs-var">pscs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CompleteMatch -&gt; IOEnv (Env DsGblEnv DsLclEnv) [ConLike])
-&gt; [CompleteMatch] -&gt; IOEnv (Env DsGblEnv DsLclEnv) [[ConLike]]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">CompleteMatch -&gt; IOEnv (Env DsGblEnv DsLclEnv) [ConLike]
</span><a href="#local-6989586621681146896"><span class="hs-identifier hs-var">fams</span></a></span><span> </span><span class="annot"><span class="annottext">[CompleteMatch]
</span><a href="#local-6989586621681146900"><span class="hs-identifier hs-var">pragmas</span></a></span><span>
</span><span id="line-684"></span><span>      </span><span class="hs-comment">-- pprTrace &quot;initPossibleMatches&quot; (ppr ty $$ ppr ty' $$ ppr tc_rep &lt;+&gt; ppr tc_fam &lt;+&gt; ppr tc_args $$ ppr (rdcs ++ pscs)) (return ())</span><span>
</span><span id="line-685"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[[ConLike]] -&gt; Maybe (NonEmpty [ConLike])
forall a. [a] -&gt; Maybe (NonEmpty a)
</span><a href="../../base/src/Data.List.NonEmpty.html#nonEmpty"><span class="hs-identifier hs-var">NonEmpty.nonEmpty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[[ConLike]]
</span><a href="#local-6989586621681146902"><span class="hs-identifier hs-var">rdcs</span></a></span><span> </span><span class="annot"><span class="annottext">[[ConLike]] -&gt; [[ConLike]] -&gt; [[ConLike]]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[[ConLike]]
</span><a href="#local-6989586621681146894"><span class="hs-identifier hs-var">pscs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-686"></span><span>        </span><span class="annot"><span class="annottext">Maybe (NonEmpty [ConLike])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; DsM VarInfo
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146924"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">vi_ty :: Type
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_ty"><span class="hs-identifier hs-var">vi_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146919"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-comment">-- Didn't find any COMPLETE sets</span><span>
</span><span id="line-687"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146892"><span class="annot"><span class="annottext">NonEmpty [ConLike]
</span><a href="#local-6989586621681146892"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; DsM VarInfo
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146924"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">vi_ty :: Type
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_ty"><span class="hs-identifier hs-var">vi_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146919"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">vi_cache :: PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_cache"><span class="hs-identifier hs-var">vi_cache</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NonEmpty ConLikeSet -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#PM"><span class="hs-identifier hs-var">PM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ConLike] -&gt; ConLikeSet
forall a. Uniquable a =&gt; [a] -&gt; UniqDSet a
</span><a href="GHC.Types.Unique.DSet.html#mkUniqDSet"><span class="hs-identifier hs-var">mkUniqDSet</span></a></span><span> </span><span class="annot"><span class="annottext">([ConLike] -&gt; ConLikeSet)
-&gt; NonEmpty [ConLike] -&gt; NonEmpty ConLikeSet
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty [ConLike]
</span><a href="#local-6989586621681146892"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-688"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#initPossibleMatches"><span class="hs-identifier hs-var">initPossibleMatches</span></a></span><span> </span><span class="annot"><span class="annottext">TyState
</span><span class="hs-identifier">_</span></span><span>     </span><span id="local-6989586621681146890"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146890"><span class="hs-identifier hs-var">vi</span></a></span></span><span>                                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; DsM VarInfo
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146890"><span class="hs-identifier hs-var">vi</span></a></span><span>
</span><span id="line-689"></span><span>
</span><span id="line-690"></span><span class="hs-comment">-- | @initLookupVarInfo ts x@ looks up the 'VarInfo' for @x@ in @ts@ and tries</span><span>
</span><span id="line-691"></span><span class="hs-comment">-- to initialise the 'vi_cache' component if it was 'NoPM' through</span><span>
</span><span id="line-692"></span><span class="hs-comment">-- 'initPossibleMatches'.</span><span>
</span><span id="line-693"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#initLookupVarInfo"><span class="hs-identifier hs-type">initLookupVarInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VarInfo"><span class="hs-identifier hs-type">VarInfo</span></a></span><span>
</span><span id="line-694"></span><span id="initLookupVarInfo"><span class="annot"><span class="annottext">initLookupVarInfo :: Delta -&gt; Id -&gt; DsM VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#initLookupVarInfo"><span class="hs-identifier hs-var hs-var">initLookupVarInfo</span></a></span></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146886"><span class="annot"><span class="annottext">TmState
</span><a href="#local-6989586621681146886"><span class="hs-identifier hs-var">ts</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">delta_ty_st :: Delta -&gt; TyState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_ty_st"><span class="hs-identifier hs-var">delta_ty_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146885"><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146885"><span class="hs-identifier hs-var">ty_st</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146884"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146884"><span class="hs-identifier hs-var">x</span></a></span></span><span>
</span><span id="line-695"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyState -&gt; VarInfo -&gt; DsM VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#initPossibleMatches"><span class="hs-identifier hs-var">initPossibleMatches</span></a></span><span> </span><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146885"><span class="hs-identifier hs-var">ty_st</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TmState -&gt; Id -&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupVarInfo"><span class="hs-identifier hs-var">lookupVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TmState
</span><a href="#local-6989586621681146886"><span class="hs-identifier hs-var">ts</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146884"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-696"></span><span>
</span><span id="line-697"></span><span class="hs-comment">{- Note [COMPLETE sets on data families]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
User-defined COMPLETE sets involving data families are attached to the family
TyCon, whereas the built-in COMPLETE set is attached to a data family instance's
representation TyCon. This matters for COMPLETE sets involving both DataCons
and PatSyns (from #17207):

  data family T a
  data family instance T () = A | B
  pattern C = B
  {-# COMPLETE A, C #-}
  f :: T () -&gt; ()
  f A = ()
  f C = ()

The match on A is actually wrapped in a CoPat, matching impedance between T ()
and its representation TyCon, which we translate as
@x | let y = x |&gt; co, A &lt;- y@ in PmCheck.

Which TyCon should we use for looking up the COMPLETE set? The representation
TyCon from the match on A would only reveal the built-in COMPLETE set, while the
data family TyCon would only give the user-defined one. But when initialising
the PossibleMatches for a given Type, we want to do so only once, because
merging different COMPLETE sets after the fact is very complicated and possibly
inefficient.

So in fact, we just *drop* the coercion arising from the CoPat when handling
handling the constraint @y ~ x |&gt; co@ in addCoreCt, just equating @y ~ x@.
We then handle the fallout in initPossibleMatches, which has to get a hand at
both the representation TyCon tc_rep and the parent data family TyCon tc_fam.
It considers three cases after having established that the Type is a TyConApp:

1. The TyCon is a vanilla data type constructor
2. The TyCon is tc_rep
3. The TyCon is tc_fam

1. is simple and subsumed by the handling of the other two.
We check for case 2. by 'tyConFamInst_maybe' and get the tc_fam out.
Otherwise (3.), we try to lookup the data family instance at that particular
type to get out the tc_rep. In case 1., this will just return the original
TyCon, so tc_rep = tc_fam afterwards.
-}</span><span>
</span><span id="line-739"></span><span>
</span><span id="line-740"></span><span class="hs-comment">------------------------------------------------</span><span>
</span><span id="line-741"></span><span class="hs-comment">-- * Exported utility functions querying 'Delta'</span><span>
</span><span id="line-742"></span><span>
</span><span id="line-743"></span><span class="hs-comment">-- | Check whether adding a constraint @x ~ BOT@ to 'Delta' succeeds.</span><span>
</span><span id="line-744"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#canDiverge"><span class="hs-identifier hs-type">canDiverge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-745"></span><span id="canDiverge"><span class="annot"><span class="annottext">canDiverge :: Delta -&gt; Id -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#canDiverge"><span class="hs-identifier hs-var hs-var">canDiverge</span></a></span></span><span> </span><span id="local-6989586621681146883"><span class="annot"><span class="annottext">delta :: Delta
</span><a href="#local-6989586621681146883"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146882"><span class="annot"><span class="annottext">TmState
</span><a href="#local-6989586621681146882"><span class="hs-identifier hs-var">ts</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146881"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146881"><span class="hs-identifier hs-var">x</span></a></span></span><span>
</span><span id="line-746"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VI"><span class="hs-identifier hs-type">VI</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681146880"><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146880"><span class="hs-identifier hs-var">pos</span></a></span></span><span> </span><span id="local-6989586621681146879"><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146879"><span class="hs-identifier hs-var">neg</span></a></span></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TmState -&gt; Id -&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupVarInfo"><span class="hs-identifier hs-var">lookupVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TmState
</span><a href="#local-6989586621681146882"><span class="hs-identifier hs-var">ts</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146881"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-747"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmAltConSet -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Types.html#isEmptyPmAltConSet"><span class="hs-identifier hs-var">isEmptyPmAltConSet</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146879"><span class="hs-identifier hs-var">neg</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">((PmAltCon, [Id], [Id]) -&gt; Bool)
-&gt; [(PmAltCon, [Id], [Id])] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id]) -&gt; Bool
forall {b}. (PmAltCon, b, [Id]) -&gt; Bool
</span><a href="#local-6989586621681146876"><span class="hs-identifier hs-var">pos_can_diverge</span></a></span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146880"><span class="hs-identifier hs-var">pos</span></a></span><span>
</span><span id="line-748"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-749"></span><span>    </span><span id="local-6989586621681146876"><span class="annot"><span class="annottext">pos_can_diverge :: (PmAltCon, b, [Id]) -&gt; Bool
</span><a href="#local-6989586621681146876"><span class="hs-identifier hs-var hs-var">pos_can_diverge</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-type">PmAltConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span id="local-6989586621681146874"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146874"><span class="hs-identifier hs-var">dc</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621681146873"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146873"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-750"></span><span>      </span><span class="hs-comment">-- See Note [Divergence of Newtype matches]</span><span>
</span><span id="line-751"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isNewTyCon"><span class="hs-identifier hs-var">isNewTyCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; TyCon
</span><a href="GHC.Core.DataCon.html#dataConTyCon"><span class="hs-identifier hs-var">dataConTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146874"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#canDiverge"><span class="hs-identifier hs-var">canDiverge</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146883"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146873"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-752"></span><span>    </span><span class="annot"><a href="#local-6989586621681146876"><span class="hs-identifier hs-var">pos_can_diverge</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon, b, [Id])
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-753"></span><span>
</span><span id="line-754"></span><span class="hs-comment">{- Note [Divergence of Newtype matches]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Newtypes behave rather strangely when compared to ordinary DataCons. In a
pattern-match, they behave like a irrefutable (lazy) match, but for inhabitation
testing purposes (e.g. at construction sites), they behave rather like a DataCon
with a *strict* field, because they don't contribute their own bottom and are
inhabited iff the wrapped type is inhabited.

This distinction becomes apparent in #17248:

  newtype T2 a = T2 a
  g _      True = ()
  g (T2 _) True = ()
  g !_     True = ()

If we treat Newtypes like we treat regular DataCons, we would mark the third
clause as redundant, which clearly is unsound. The solution:
1. When compiling the PmCon guard in 'pmCompileTree', don't add a @DivergeIf@,
   because the match will never diverge.
2. Regard @T2 x@ as 'canDiverge' iff @x@ 'canDiverge'. E.g. @T2 x ~ _|_@ &lt;=&gt;
   @x ~ _|_@. This way, the third clause will still be marked as inaccessible
   RHS instead of redundant.
3. When testing for inhabitants ('mkOneConFull'), we regard the newtype field as
   strict, so that the newtype is inhabited iff its field is inhabited.
-}</span><span>
</span><span id="line-779"></span><span>
</span><span id="line-780"></span><span id="local-6989586621681147698"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupRefuts"><span class="hs-identifier hs-type">lookupRefuts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Uniquable"><span class="hs-identifier hs-type">Uniquable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681147698"><span class="hs-identifier hs-type">k</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681147698"><span class="hs-identifier hs-type">k</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-781"></span><span class="hs-comment">-- Unfortunately we need the extra bit of polymorphism and the unfortunate</span><span>
</span><span id="line-782"></span><span class="hs-comment">-- duplication of lookupVarInfo here.</span><span>
</span><span id="line-783"></span><span id="lookupRefuts"><span class="annot"><span class="annottext">lookupRefuts :: forall k. Uniquable k =&gt; Delta -&gt; k -&gt; [PmAltCon]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupRefuts"><span class="hs-identifier hs-var hs-var">lookupRefuts</span></a></span></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146870"><span class="annot"><span class="annottext">ts :: TmState
</span><a href="#local-6989586621681146870"><span class="hs-identifier hs-var">ts</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#SDIE"><span class="hs-identifier hs-type">SDIE</span></a></span><span> </span><span id="local-6989586621681146868"><span class="annot"><span class="annottext">DIdEnv (Shared VarInfo)
</span><a href="#local-6989586621681146868"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146867"><span class="annot"><span class="annottext">k
</span><a href="#local-6989586621681146867"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-784"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DIdEnv (Shared VarInfo) -&gt; Unique -&gt; Maybe (Shared VarInfo)
forall key elt. UniqDFM key elt -&gt; Unique -&gt; Maybe elt
</span><a href="GHC.Types.Unique.DFM.html#lookupUDFM_Directly"><span class="hs-identifier hs-var">lookupUDFM_Directly</span></a></span><span> </span><span class="annot"><span class="annottext">DIdEnv (Shared VarInfo)
</span><a href="#local-6989586621681146868"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">k -&gt; Unique
forall a. Uniquable a =&gt; a -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span> </span><span class="annot"><span class="annottext">k
</span><a href="#local-6989586621681146867"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-785"></span><span>    </span><span class="annot"><span class="annottext">Maybe (Shared VarInfo)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-786"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681146863"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146863"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PmAltConSet -&gt; [PmAltCon]
</span><a href="GHC.HsToCore.PmCheck.Types.html#pmAltConSetElems"><span class="hs-identifier hs-var">pmAltConSetElems</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarInfo -&gt; PmAltConSet
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_neg"><span class="hs-identifier hs-var hs-var">vi_neg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TmState -&gt; Id -&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupVarInfo"><span class="hs-identifier hs-var">lookupVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TmState
</span><a href="#local-6989586621681146870"><span class="hs-identifier hs-var">ts</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146863"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-787"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Entry"><span class="hs-identifier hs-type">Entry</span></a></span><span> </span><span id="local-6989586621681146859"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146859"><span class="hs-identifier hs-var">vi</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PmAltConSet -&gt; [PmAltCon]
</span><a href="GHC.HsToCore.PmCheck.Types.html#pmAltConSetElems"><span class="hs-identifier hs-var">pmAltConSetElems</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarInfo -&gt; PmAltConSet
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_neg"><span class="hs-identifier hs-var hs-var">vi_neg</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146859"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-788"></span><span>
</span><span id="line-789"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#isDataConSolution"><span class="hs-identifier hs-type">isDataConSolution</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-790"></span><span id="isDataConSolution"><span class="annot"><span class="annottext">isDataConSolution :: (PmAltCon, [Id], [Id]) -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#isDataConSolution"><span class="hs-identifier hs-var hs-var">isDataConSolution</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-type">PmAltConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-791"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#isDataConSolution"><span class="hs-identifier hs-var">isDataConSolution</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id])
</span><span class="hs-identifier">_</span></span><span>                                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-792"></span><span>
</span><span id="line-793"></span><span class="hs-comment">-- @lookupSolution delta x@ picks a single solution ('vi_pos') of @x@ from</span><span>
</span><span id="line-794"></span><span class="hs-comment">-- possibly many, preferring 'RealDataCon' solutions whenever possible.</span><span>
</span><span id="line-795"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupSolution"><span class="hs-identifier hs-type">lookupSolution</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-796"></span><span id="lookupSolution"><span class="annot"><span class="annottext">lookupSolution :: Delta -&gt; Id -&gt; Maybe (PmAltCon, [Id], [Id])
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupSolution"><span class="hs-identifier hs-var hs-var">lookupSolution</span></a></span></span><span> </span><span id="local-6989586621681146857"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146857"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span id="local-6989586621681146856"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146856"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; [(PmAltCon, [Id], [Id])]
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_pos"><span class="hs-identifier hs-var hs-var">vi_pos</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TmState -&gt; Id -&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#lookupVarInfo"><span class="hs-identifier hs-var">lookupVarInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var hs-var">delta_tm_st</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146857"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146856"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-797"></span><span>  </span><span class="hs-special">[</span><span class="hs-special">]</span><span>                                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe (PmAltCon, [Id], [Id])
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-798"></span><span>  </span><span id="local-6989586621681146854"><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146854"><span class="hs-identifier hs-var">pos</span></a></span></span><span>
</span><span id="line-799"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146853"><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id])
</span><a href="#local-6989586621681146853"><span class="hs-identifier hs-var">sol</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((PmAltCon, [Id], [Id]) -&gt; Bool)
-&gt; [(PmAltCon, [Id], [Id])] -&gt; Maybe (PmAltCon, [Id], [Id])
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Maybe a
</span><a href="../../base/src/Data.Foldable.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id]) -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#isDataConSolution"><span class="hs-identifier hs-var">isDataConSolution</span></a></span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146854"><span class="hs-identifier hs-var">pos</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id]) -&gt; Maybe (PmAltCon, [Id], [Id])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id])
</span><a href="#local-6989586621681146853"><span class="hs-identifier hs-var">sol</span></a></span><span>
</span><span id="line-800"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id]) -&gt; Maybe (PmAltCon, [Id], [Id])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])] -&gt; (PmAltCon, [Id], [Id])
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146854"><span class="hs-identifier hs-var">pos</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-801"></span><span>
</span><span id="line-802"></span><span class="hs-comment">-------------------------------</span><span>
</span><span id="line-803"></span><span class="hs-comment">-- * Adding facts to the oracle</span><span>
</span><span id="line-804"></span><span>
</span><span id="line-805"></span><span class="hs-comment">-- | A term constraint.</span><span>
</span><span id="line-806"></span><span class="hs-keyword">data</span><span> </span><span id="TmCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCt"><span class="hs-identifier hs-var">TmCt</span></a></span></span><span>
</span><span id="line-807"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="TmVarCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmVarCt"><span class="hs-identifier hs-var">TmVarCt</span></a></span></span><span>     </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-808"></span><span>  </span><span class="hs-comment">-- ^ @TmVarCt x y@ encodes &quot;x ~ y&quot;, equating @x@ and @y@.</span><span>
</span><span id="line-809"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="TmCoreCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCoreCt"><span class="hs-identifier hs-var">TmCoreCt</span></a></span></span><span>    </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-810"></span><span>  </span><span class="hs-comment">-- ^ @TmCoreCt x e@ encodes &quot;x ~ e&quot;, equating @x@ with the 'CoreExpr' @e@.</span><span>
</span><span id="line-811"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="TmConCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmConCt"><span class="hs-identifier hs-var">TmConCt</span></a></span></span><span>     </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span> </span><span class="hs-glyph">!</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-812"></span><span>  </span><span class="hs-comment">-- ^ @TmConCt x K tvs ys@ encodes &quot;x ~ K @tvs ys&quot;, equating @x@ with the 'PmAltCon'</span><span>
</span><span id="line-813"></span><span>  </span><span class="hs-comment">-- application @K @tvs ys@.</span><span>
</span><span id="line-814"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="TmNotConCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmNotConCt"><span class="hs-identifier hs-var">TmNotConCt</span></a></span></span><span>  </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span>
</span><span id="line-815"></span><span>  </span><span class="hs-comment">-- ^ @TmNotConCt x K@ encodes &quot;x /~ K&quot;, asserting that @x@ can't be headed</span><span>
</span><span id="line-816"></span><span>  </span><span class="hs-comment">-- by @K@.</span><span>
</span><span id="line-817"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="TmBotCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmBotCt"><span class="hs-identifier hs-var">TmBotCt</span></a></span></span><span>     </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-818"></span><span>  </span><span class="hs-comment">-- ^ @TmBotCt x@ encodes &quot;x ~ &#8869;&quot;, equating @x@ to &#8869;.</span><span>
</span><span id="line-819"></span><span>  </span><span class="hs-comment">-- by @K@.</span><span>
</span><span id="line-820"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="TmNotBotCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmNotBotCt"><span class="hs-identifier hs-var">TmNotBotCt</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-821"></span><span>  </span><span class="hs-comment">-- ^ @TmNotBotCt x y@ encodes &quot;x /~ &#8869;&quot;, asserting that @x@ can't be &#8869;.</span><span>
</span><span id="line-822"></span><span>
</span><span id="line-823"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681146843"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCt"><span class="hs-identifier hs-type">TmCt</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-824"></span><span>  </span><span id="local-6989586621681146832"><span class="annot"><span class="annottext">ppr :: TmCt -&gt; SDoc
</span><a href="#local-6989586621681146832"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmVarCt"><span class="hs-identifier hs-type">TmVarCt</span></a></span><span> </span><span id="local-6989586621681146831"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146831"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146830"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146830"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146831"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'~'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146830"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-825"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCoreCt"><span class="hs-identifier hs-type">TmCoreCt</span></a></span><span> </span><span id="local-6989586621681146828"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146828"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146827"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146827"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146828"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'~'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146827"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-826"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmConCt"><span class="hs-identifier hs-type">TmConCt</span></a></span><span> </span><span id="local-6989586621681146826"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146826"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146825"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146825"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621681146824"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146824"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681146823"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146823"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146826"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'~'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmAltCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146825"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681146821"><span class="hs-identifier hs-var">pp_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; [SDoc] -&gt; [SDoc]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681146820"><span class="hs-identifier hs-var">pp_args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-827"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-828"></span><span>      </span><span id="local-6989586621681146821"><span class="annot"><span class="annottext">pp_tvs :: [SDoc]
</span><a href="#local-6989586621681146821"><span class="hs-identifier hs-var hs-var">pp_tvs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; SDoc) -&gt; [Id] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'@'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; (Id -&gt; SDoc) -&gt; Id -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146824"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-829"></span><span>      </span><span id="local-6989586621681146820"><span class="annot"><span class="annottext">pp_args :: [SDoc]
</span><a href="#local-6989586621681146820"><span class="hs-identifier hs-var hs-var">pp_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; SDoc) -&gt; [Id] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146823"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-830"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmNotConCt"><span class="hs-identifier hs-type">TmNotConCt</span></a></span><span> </span><span id="local-6989586621681146816"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146816"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146815"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146815"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146816"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;/~&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146815"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-831"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmBotCt"><span class="hs-identifier hs-type">TmBotCt</span></a></span><span> </span><span id="local-6989586621681146814"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146814"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146814"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;~ &#8869;&quot;</span></span><span>
</span><span id="line-832"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmNotBotCt"><span class="hs-identifier hs-type">TmNotBotCt</span></a></span><span> </span><span id="local-6989586621681146813"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146813"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146813"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;/~ &#8869;&quot;</span></span><span>
</span><span id="line-833"></span><span>
</span><span id="line-834"></span><span class="hs-keyword">type</span><span> </span><span id="TyCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TyCt"><span class="hs-identifier hs-var">TyCt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span>
</span><span id="line-835"></span><span>
</span><span id="line-836"></span><span class="hs-comment">-- | An oracle constraint.</span><span>
</span><span id="line-837"></span><span class="hs-keyword">data</span><span> </span><span id="PmCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-var">PmCt</span></a></span></span><span>
</span><span id="line-838"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="PmTyCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTyCt"><span class="hs-identifier hs-var">PmTyCt</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TyCt"><span class="hs-identifier hs-type">TyCt</span></a></span><span>
</span><span id="line-839"></span><span>  </span><span class="hs-comment">-- ^ @PmTy pred_ty@ carries 'PredType's, for example equality constraints.</span><span>
</span><span id="line-840"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="PmTmCt"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-var">PmTmCt</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCt"><span class="hs-identifier hs-type">TmCt</span></a></span><span>
</span><span id="line-841"></span><span>  </span><span class="hs-comment">-- ^ A term constraint.</span><span>
</span><span id="line-842"></span><span>
</span><span id="line-843"></span><span class="hs-keyword">type</span><span> </span><span id="PmCts"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCts"><span class="hs-identifier hs-var">PmCts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span>
</span><span id="line-844"></span><span>
</span><span id="line-845"></span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmVarCt"><span class="hs-identifier hs-type">PmVarCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span>
</span><span id="line-846"></span><span class="hs-keyword">pattern</span><span> </span><span id="%24mPmVarCt"><span id="%24bPmVarCt"><span id="PmVarCt"><span class="annot"><span class="annottext">$mPmVarCt :: forall {r}. PmCt -&gt; (Id -&gt; Id -&gt; r) -&gt; (Void# -&gt; r) -&gt; r
$bPmVarCt :: Id -&gt; Id -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#%24mPmVarCt"><span class="hs-identifier hs-var hs-var hs-var">PmVarCt</span></a></span></span></span></span><span> </span><span class="annot"><a href="#local-6989586621681146809"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681146808"><span class="hs-identifier hs-type">y</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-type">PmTmCt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmVarCt"><span class="hs-identifier hs-type">TmVarCt</span></a></span><span> </span><span id="local-6989586621681146809"><span class="annot"><a href="#local-6989586621681146809"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146808"><span class="annot"><a href="#local-6989586621681146808"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-847"></span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCoreCt"><span class="hs-identifier hs-type">PmCoreCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span>
</span><span id="line-848"></span><span class="hs-keyword">pattern</span><span> </span><span id="%24mPmCoreCt"><span id="%24bPmCoreCt"><span id="PmCoreCt"><span class="annot"><span class="annottext">$mPmCoreCt :: forall {r}. PmCt -&gt; (Id -&gt; CoreExpr -&gt; r) -&gt; (Void# -&gt; r) -&gt; r
$bPmCoreCt :: Id -&gt; CoreExpr -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#%24mPmCoreCt"><span class="hs-identifier hs-var hs-var hs-var">PmCoreCt</span></a></span></span></span></span><span> </span><span class="annot"><a href="#local-6989586621681146805"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681146804"><span class="hs-identifier hs-type">e</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-type">PmTmCt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCoreCt"><span class="hs-identifier hs-type">TmCoreCt</span></a></span><span> </span><span id="local-6989586621681146805"><span class="annot"><a href="#local-6989586621681146805"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146804"><span class="annot"><a href="#local-6989586621681146804"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-849"></span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmConCt"><span class="hs-identifier hs-type">PmConCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span>
</span><span id="line-850"></span><span class="hs-keyword">pattern</span><span> </span><span id="%24mPmConCt"><span id="%24bPmConCt"><span id="PmConCt"><span class="annot"><span class="annottext">$mPmConCt :: forall {r}.
PmCt -&gt; (Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; r) -&gt; (Void# -&gt; r) -&gt; r
$bPmConCt :: Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#%24mPmConCt"><span class="hs-identifier hs-var hs-var hs-var">PmConCt</span></a></span></span></span></span><span> </span><span class="annot"><a href="#local-6989586621681146801"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681146800"><span class="hs-identifier hs-type">con</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681146799"><span class="hs-identifier hs-type">tvs</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681146798"><span class="hs-identifier hs-type">args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-type">PmTmCt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmConCt"><span class="hs-identifier hs-type">TmConCt</span></a></span><span> </span><span id="local-6989586621681146801"><span class="annot"><a href="#local-6989586621681146801"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146800"><span class="annot"><a href="#local-6989586621681146800"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621681146799"><span class="annot"><a href="#local-6989586621681146799"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681146798"><span class="annot"><a href="#local-6989586621681146798"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-851"></span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmNotConCt"><span class="hs-identifier hs-type">PmNotConCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span>
</span><span id="line-852"></span><span class="hs-keyword">pattern</span><span> </span><span id="%24mPmNotConCt"><span id="%24bPmNotConCt"><span id="PmNotConCt"><span class="annot"><span class="annottext">$mPmNotConCt :: forall {r}. PmCt -&gt; (Id -&gt; PmAltCon -&gt; r) -&gt; (Void# -&gt; r) -&gt; r
$bPmNotConCt :: Id -&gt; PmAltCon -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#%24mPmNotConCt"><span class="hs-identifier hs-var hs-var hs-var">PmNotConCt</span></a></span></span></span></span><span> </span><span class="annot"><a href="#local-6989586621681146795"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681146794"><span class="hs-identifier hs-type">con</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-type">PmTmCt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmNotConCt"><span class="hs-identifier hs-type">TmNotConCt</span></a></span><span> </span><span id="local-6989586621681146795"><span class="annot"><a href="#local-6989586621681146795"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146794"><span class="annot"><a href="#local-6989586621681146794"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-853"></span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmBotCt"><span class="hs-identifier hs-type">PmBotCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span>
</span><span id="line-854"></span><span class="hs-keyword">pattern</span><span> </span><span id="%24mPmBotCt"><span id="%24bPmBotCt"><span id="PmBotCt"><span class="annot"><span class="annottext">$mPmBotCt :: forall {r}. PmCt -&gt; (Id -&gt; r) -&gt; (Void# -&gt; r) -&gt; r
$bPmBotCt :: Id -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#%24mPmBotCt"><span class="hs-identifier hs-var hs-var hs-var">PmBotCt</span></a></span></span></span></span><span> </span><span class="annot"><a href="#local-6989586621681146791"><span class="hs-identifier hs-type">x</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-type">PmTmCt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmBotCt"><span class="hs-identifier hs-type">TmBotCt</span></a></span><span> </span><span id="local-6989586621681146791"><span class="annot"><a href="#local-6989586621681146791"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-855"></span><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmNotBotCt"><span class="hs-identifier hs-type">PmNotBotCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span>
</span><span id="line-856"></span><span class="hs-keyword">pattern</span><span> </span><span id="%24mPmNotBotCt"><span id="%24bPmNotBotCt"><span id="PmNotBotCt"><span class="annot"><span class="annottext">$mPmNotBotCt :: forall {r}. PmCt -&gt; (Id -&gt; r) -&gt; (Void# -&gt; r) -&gt; r
$bPmNotBotCt :: Id -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#%24mPmNotBotCt"><span class="hs-identifier hs-var hs-var hs-var">PmNotBotCt</span></a></span></span></span></span><span> </span><span class="annot"><a href="#local-6989586621681146788"><span class="hs-identifier hs-type">x</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-type">PmTmCt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmNotBotCt"><span class="hs-identifier hs-type">TmNotBotCt</span></a></span><span> </span><span id="local-6989586621681146788"><span class="annot"><a href="#local-6989586621681146788"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-857"></span><span class="hs-pragma">{-# COMPLETE</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTyCt"><span class="hs-pragma hs-type">PmTyCt</span></a></span><span class="hs-pragma">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmVarCt"><span class="hs-pragma hs-type">PmVarCt</span></a></span><span class="hs-pragma">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCoreCt"><span class="hs-pragma hs-type">PmCoreCt</span></a></span><span class="hs-pragma">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmConCt"><span class="hs-pragma hs-type">PmConCt</span></a></span><span class="hs-pragma">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmNotConCt"><span class="hs-pragma hs-type">PmNotConCt</span></a></span><span class="hs-pragma">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmBotCt"><span class="hs-pragma hs-type">PmBotCt</span></a></span><span class="hs-pragma">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmNotBotCt"><span class="hs-pragma hs-type">PmNotBotCt</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-858"></span><span>
</span><span id="line-859"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681146785"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-860"></span><span>  </span><span id="local-6989586621681146782"><span class="annot"><span class="annottext">ppr :: PmCt -&gt; SDoc
</span><a href="#local-6989586621681146782"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTyCt"><span class="hs-identifier hs-type">PmTyCt</span></a></span><span> </span><span id="local-6989586621681146781"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146781"><span class="hs-identifier hs-var">pred_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146781"><span class="hs-identifier hs-var">pred_ty</span></a></span><span>
</span><span id="line-861"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-type">PmTmCt</span></a></span><span> </span><span id="local-6989586621681146780"><span class="annot"><span class="annottext">TmCt
</span><a href="#local-6989586621681146780"><span class="hs-identifier hs-var">tm_ct</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TmCt -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TmCt
</span><a href="#local-6989586621681146780"><span class="hs-identifier hs-var">tm_ct</span></a></span><span>
</span><span id="line-862"></span><span>
</span><span id="line-863"></span><span class="hs-comment">-- | Adds new constraints to 'Delta' and returns 'Nothing' if that leads to a</span><span>
</span><span id="line-864"></span><span class="hs-comment">-- contradiction.</span><span>
</span><span id="line-865"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addPmCts"><span class="hs-identifier hs-type">addPmCts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCts"><span class="hs-identifier hs-type">PmCts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-866"></span><span class="hs-comment">-- See Note [TmState invariants].</span><span>
</span><span id="line-867"></span><span id="addPmCts"><span class="annot"><span class="annottext">addPmCts :: Delta -&gt; PmCts -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addPmCts"><span class="hs-identifier hs-var hs-var">addPmCts</span></a></span></span><span> </span><span id="local-6989586621681146779"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146779"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span id="local-6989586621681146778"><span class="annot"><span class="annottext">PmCts
</span><a href="#local-6989586621681146778"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-868"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146777"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146777"><span class="hs-identifier hs-var">ty_cts</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146776"><span class="annot"><span class="annottext">[TmCt]
</span><a href="#local-6989586621681146776"><span class="hs-identifier hs-var">tm_cts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmCts -&gt; ([Type], [TmCt])
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#partitionTyTmCts"><span class="hs-identifier hs-var">partitionTyTmCts</span></a></span><span> </span><span class="annot"><span class="annottext">PmCts
</span><a href="#local-6989586621681146778"><span class="hs-identifier hs-var">cts</span></a></span><span>
</span><span id="line-869"></span><span>  </span><span class="annot"><span class="annottext">Delta -&gt; SatisfiabilityCheck -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#runSatisfiabilityCheck"><span class="hs-identifier hs-var">runSatisfiabilityCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146779"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">(SatisfiabilityCheck -&gt; DsM (Maybe Delta))
-&gt; SatisfiabilityCheck -&gt; DsM (Maybe Delta)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SatisfiabilityCheck] -&gt; SatisfiabilityCheck
forall a. Monoid a =&gt; [a] -&gt; a
</span><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var">mconcat</span></a></span><span>
</span><span id="line-870"></span><span>    </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bag Type -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tyIsSatisfiable"><span class="hs-identifier hs-var">tyIsSatisfiable</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; Bag Type
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146777"><span class="hs-identifier hs-var">ty_cts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-871"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag TmCt -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tmIsSatisfiable"><span class="hs-identifier hs-var">tmIsSatisfiable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TmCt] -&gt; Bag TmCt
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[TmCt]
</span><a href="#local-6989586621681146776"><span class="hs-identifier hs-var">tm_cts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-872"></span><span>    </span><span class="hs-special">]</span><span>
</span><span id="line-873"></span><span>
</span><span id="line-874"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#partitionTyTmCts"><span class="hs-identifier hs-type">partitionTyTmCts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCts"><span class="hs-identifier hs-type">PmCts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TyCt"><span class="hs-identifier hs-type">TyCt</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCt"><span class="hs-identifier hs-type">TmCt</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-875"></span><span id="partitionTyTmCts"><span class="annot"><span class="annottext">partitionTyTmCts :: PmCts -&gt; ([Type], [TmCt])
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#partitionTyTmCts"><span class="hs-identifier hs-var hs-var">partitionTyTmCts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Either Type TmCt] -&gt; ([Type], [TmCt])
forall a b. [Either a b] -&gt; ([a], [b])
</span><a href="../../base/src/Data.Either.html#partitionEithers"><span class="hs-identifier hs-var">partitionEithers</span></a></span><span> </span><span class="annot"><span class="annottext">([Either Type TmCt] -&gt; ([Type], [TmCt]))
-&gt; (PmCts -&gt; [Either Type TmCt]) -&gt; PmCts -&gt; ([Type], [TmCt])
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(PmCt -&gt; Either Type TmCt) -&gt; [PmCt] -&gt; [Either Type TmCt]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">PmCt -&gt; Either Type TmCt
</span><a href="#local-6989586621681146774"><span class="hs-identifier hs-var">to_either</span></a></span><span> </span><span class="annot"><span class="annottext">([PmCt] -&gt; [Either Type TmCt])
-&gt; (PmCts -&gt; [PmCt]) -&gt; PmCts -&gt; [Either Type TmCt]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">PmCts -&gt; [PmCt]
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier hs-var">toList</span></a></span><span>
</span><span id="line-876"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-877"></span><span>    </span><span id="local-6989586621681146774"><span class="annot"><span class="annottext">to_either :: PmCt -&gt; Either Type TmCt
</span><a href="#local-6989586621681146774"><span class="hs-identifier hs-var hs-var">to_either</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTyCt"><span class="hs-identifier hs-type">PmTyCt</span></a></span><span> </span><span id="local-6989586621681146773"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146773"><span class="hs-identifier hs-var">pred_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Either Type TmCt
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146773"><span class="hs-identifier hs-var">pred_ty</span></a></span><span>
</span><span id="line-878"></span><span>    </span><span class="annot"><a href="#local-6989586621681146774"><span class="hs-identifier hs-var">to_either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTmCt"><span class="hs-identifier hs-type">PmTmCt</span></a></span><span> </span><span id="local-6989586621681146772"><span class="annot"><span class="annottext">TmCt
</span><a href="#local-6989586621681146772"><span class="hs-identifier hs-var">tm_ct</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TmCt -&gt; Either Type TmCt
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">TmCt
</span><a href="#local-6989586621681146772"><span class="hs-identifier hs-var">tm_ct</span></a></span><span>
</span><span id="line-879"></span><span>
</span><span id="line-880"></span><span class="hs-comment">-- | Adds a single term constraint by dispatching to the various term oracle</span><span>
</span><span id="line-881"></span><span class="hs-comment">-- functions.</span><span>
</span><span id="line-882"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addTmCt"><span class="hs-identifier hs-type">addTmCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCt"><span class="hs-identifier hs-type">TmCt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-883"></span><span id="addTmCt"><span class="annot"><span class="annottext">addTmCt :: Delta -&gt; TmCt -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addTmCt"><span class="hs-identifier hs-var hs-var">addTmCt</span></a></span></span><span> </span><span id="local-6989586621681146771"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146771"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmVarCt"><span class="hs-identifier hs-type">TmVarCt</span></a></span><span> </span><span id="local-6989586621681146770"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146770"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146769"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146769"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addVarCt"><span class="hs-identifier hs-var">addVarCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146771"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146770"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146769"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-884"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addTmCt"><span class="hs-identifier hs-var">addTmCt</span></a></span><span> </span><span id="local-6989586621681146767"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146767"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmCoreCt"><span class="hs-identifier hs-type">TmCoreCt</span></a></span><span> </span><span id="local-6989586621681146766"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146766"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146765"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146765"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; CoreExpr -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addCoreCt"><span class="hs-identifier hs-var">addCoreCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146767"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146766"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146765"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-885"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addTmCt"><span class="hs-identifier hs-var">addTmCt</span></a></span><span> </span><span id="local-6989586621681146763"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146763"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmConCt"><span class="hs-identifier hs-type">TmConCt</span></a></span><span> </span><span id="local-6989586621681146762"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146762"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146761"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146761"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621681146760"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146760"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681146759"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146759"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addConCt"><span class="hs-identifier hs-var">addConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146763"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146762"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146761"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146760"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146759"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-886"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addTmCt"><span class="hs-identifier hs-var">addTmCt</span></a></span><span> </span><span id="local-6989586621681146757"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146757"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmNotConCt"><span class="hs-identifier hs-type">TmNotConCt</span></a></span><span> </span><span id="local-6989586621681146756"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146756"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146755"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146755"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; PmAltCon -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addNotConCt"><span class="hs-identifier hs-var">addNotConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146757"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146756"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146755"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-887"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addTmCt"><span class="hs-identifier hs-var">addTmCt</span></a></span><span> </span><span id="local-6989586621681146753"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146753"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmBotCt"><span class="hs-identifier hs-type">TmBotCt</span></a></span><span> </span><span id="local-6989586621681146752"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146752"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addBotCt"><span class="hs-identifier hs-var">addBotCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146753"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146752"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-888"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addTmCt"><span class="hs-identifier hs-var">addTmCt</span></a></span><span> </span><span id="local-6989586621681146750"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146750"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#TmNotBotCt"><span class="hs-identifier hs-type">TmNotBotCt</span></a></span><span> </span><span id="local-6989586621681146749"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146749"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addNotBotCt"><span class="hs-identifier hs-var">addNotBotCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146750"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146749"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-889"></span><span>
</span><span id="line-890"></span><span class="hs-comment">-- | Adds the constraint @x ~ &#8869;@, e.g. that evaluation of a particular 'Id' @x@</span><span>
</span><span id="line-891"></span><span class="hs-comment">-- surely diverges.</span><span>
</span><span id="line-892"></span><span class="hs-comment">--</span><span>
</span><span id="line-893"></span><span class="hs-comment">-- Only that's a lie, because we don't currently preserve the fact in 'Delta'</span><span>
</span><span id="line-894"></span><span class="hs-comment">-- after we checked compatibility. See Note [Preserving TmBotCt]</span><span>
</span><span id="line-895"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addBotCt"><span class="hs-identifier hs-type">addBotCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-896"></span><span id="addBotCt"><span class="annot"><span class="annottext">addBotCt :: Delta -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addBotCt"><span class="hs-identifier hs-var hs-var">addBotCt</span></a></span></span><span> </span><span id="local-6989586621681146747"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146747"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span id="local-6989586621681146746"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146746"><span class="hs-identifier hs-var">x</span></a></span></span><span>
</span><span id="line-897"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#canDiverge"><span class="hs-identifier hs-var">canDiverge</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146747"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146746"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146747"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-898"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM Delta
forall (m :: * -&gt; *) a. MonadPlus m =&gt; m a
</span><a href="../../base/src/GHC.Base.html#mzero"><span class="hs-identifier hs-var">mzero</span></a></span><span>
</span><span id="line-899"></span><span>
</span><span id="line-900"></span><span class="hs-comment">{- Note [Preserving TmBotCt]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Whenever we add a new constraint to 'Delta' via 'addTmCt', we want to check it
for compatibility with existing constraints in the modeled indert set and then
add it the constraint itself to the inert set.
For a 'TmBotCt' @x ~ &#8869;@ we don't actually add it to the inert set after checking
it for compatibility with 'Delta'.
And that is fine in the context of the patter-match checking algorithm!
Whenever we add a 'TmBotCt' (we only do so for checking divergence of bang
patterns and strict constructor matches), we don't add any more constraints to
the inert set afterwards, so we don't need to preserve it.
-}</span><span>
</span><span id="line-912"></span><span>
</span><span id="line-913"></span><span class="hs-comment">-- | Record a @x ~/ K@ constraint, e.g. that a particular 'Id' @x@ can't</span><span>
</span><span id="line-914"></span><span class="hs-comment">-- take the shape of a 'PmAltCon' @K@ in the 'Delta' and return @Nothing@ if</span><span>
</span><span id="line-915"></span><span class="hs-comment">-- that leads to a contradiction.</span><span>
</span><span id="line-916"></span><span class="hs-comment">-- See Note [TmState invariants].</span><span>
</span><span id="line-917"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addNotConCt"><span class="hs-identifier hs-type">addNotConCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-918"></span><span id="addNotConCt"><span class="annot"><span class="annottext">addNotConCt :: Delta -&gt; Id -&gt; PmAltCon -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addNotConCt"><span class="hs-identifier hs-var hs-var">addNotConCt</span></a></span></span><span> </span><span id="local-6989586621681146745"><span class="annot"><span class="annottext">delta :: Delta
</span><a href="#local-6989586621681146745"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span> </span><span id="local-6989586621681146744"><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146744"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681146743"><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146743"><span class="hs-identifier hs-var">reps</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146742"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146742"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146741"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146741"><span class="hs-identifier hs-var">nalt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-919"></span><span>  </span><span id="local-6989586621681146740"><span class="annot"><span class="annottext">vi :: VarInfo
</span><a href="#local-6989586621681146740"><span class="hs-identifier hs-var">vi</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VI"><span class="hs-identifier hs-type">VI</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681146739"><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146739"><span class="hs-identifier hs-var">pos</span></a></span></span><span> </span><span id="local-6989586621681146738"><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146738"><span class="hs-identifier hs-var">neg</span></a></span></span><span> </span><span id="local-6989586621681146737"><span class="annot"><span class="annottext">PossibleMatches
</span><a href="#local-6989586621681146737"><span class="hs-identifier hs-var">pm</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM VarInfo -&gt; MaybeT DsM VarInfo
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; DsM VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#initLookupVarInfo"><span class="hs-identifier hs-var">initLookupVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146745"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146742"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-920"></span><span>  </span><span class="hs-comment">-- 1. Bail out quickly when nalt contradicts a solution</span><span>
</span><span id="line-921"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146735"><span class="annot"><span class="annottext">contradicts :: PmAltCon -&gt; (PmAltCon, b, c) -&gt; Bool
</span><a href="#local-6989586621681146735"><span class="hs-identifier hs-var hs-var">contradicts</span></a></span></span><span> </span><span id="local-6989586621681146734"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146734"><span class="hs-identifier hs-var">nalt</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146733"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146733"><span class="hs-identifier hs-var">cl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146732"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681146732"><span class="hs-identifier hs-var">_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146731"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621681146731"><span class="hs-identifier hs-var">_args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmAltCon -&gt; PmAltCon -&gt; PmEquality
</span><a href="GHC.HsToCore.PmCheck.Types.html#eqPmAltCon"><span class="hs-identifier hs-var">eqPmAltCon</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146733"><span class="hs-identifier hs-var">cl</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146734"><span class="hs-identifier hs-var">nalt</span></a></span><span> </span><span class="annot"><span class="annottext">PmEquality -&gt; PmEquality -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">PmEquality
</span><a href="GHC.HsToCore.PmCheck.Types.html#Equal"><span class="hs-identifier hs-var">Equal</span></a></span><span>
</span><span id="line-922"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; MaybeT DsM ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((PmAltCon, [Id], [Id]) -&gt; Bool)
-&gt; [(PmAltCon, [Id], [Id])] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmAltCon -&gt; (PmAltCon, [Id], [Id]) -&gt; Bool
forall {b} {c}. PmAltCon -&gt; (PmAltCon, b, c) -&gt; Bool
</span><a href="#local-6989586621681146735"><span class="hs-identifier hs-var">contradicts</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146741"><span class="hs-identifier hs-var">nalt</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146739"><span class="hs-identifier hs-var">pos</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-923"></span><span>  </span><span class="hs-comment">-- 2. Only record the new fact when it's not already implied by one of the</span><span>
</span><span id="line-924"></span><span>  </span><span class="hs-comment">-- solutions</span><span>
</span><span id="line-925"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146726"><span class="annot"><span class="annottext">implies :: PmAltCon -&gt; (PmAltCon, b, c) -&gt; Bool
</span><a href="#local-6989586621681146726"><span class="hs-identifier hs-var hs-var">implies</span></a></span></span><span> </span><span id="local-6989586621681146725"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146725"><span class="hs-identifier hs-var">nalt</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146724"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146724"><span class="hs-identifier hs-var">cl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146723"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681146723"><span class="hs-identifier hs-var">_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146722"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621681146722"><span class="hs-identifier hs-var">_args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmAltCon -&gt; PmAltCon -&gt; PmEquality
</span><a href="GHC.HsToCore.PmCheck.Types.html#eqPmAltCon"><span class="hs-identifier hs-var">eqPmAltCon</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146724"><span class="hs-identifier hs-var">cl</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146725"><span class="hs-identifier hs-var">nalt</span></a></span><span> </span><span class="annot"><span class="annottext">PmEquality -&gt; PmEquality -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">PmEquality
</span><a href="GHC.HsToCore.PmCheck.Types.html#Disjoint"><span class="hs-identifier hs-var">Disjoint</span></a></span><span>
</span><span id="line-926"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146719"><span class="annot"><span class="annottext">neg' :: PmAltConSet
</span><a href="#local-6989586621681146719"><span class="hs-identifier hs-var hs-var">neg'</span></a></span></span><span>
</span><span id="line-927"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">((PmAltCon, [Id], [Id]) -&gt; Bool)
-&gt; [(PmAltCon, [Id], [Id])] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmAltCon -&gt; (PmAltCon, [Id], [Id]) -&gt; Bool
forall {b} {c}. PmAltCon -&gt; (PmAltCon, b, c) -&gt; Bool
</span><a href="#local-6989586621681146726"><span class="hs-identifier hs-var">implies</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146741"><span class="hs-identifier hs-var">nalt</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146739"><span class="hs-identifier hs-var">pos</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146738"><span class="hs-identifier hs-var">neg</span></a></span><span>
</span><span id="line-928"></span><span>        </span><span class="hs-comment">-- See Note [Completeness checking with required Thetas]</span><span>
</span><span id="line-929"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">PmAltCon -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#hasRequiredTheta"><span class="hs-identifier hs-var">hasRequiredTheta</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146741"><span class="hs-identifier hs-var">nalt</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146738"><span class="hs-identifier hs-var">neg</span></a></span><span>
</span><span id="line-930"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmAltConSet -&gt; PmAltCon -&gt; PmAltConSet
</span><a href="GHC.HsToCore.PmCheck.Types.html#extendPmAltConSet"><span class="hs-identifier hs-var">extendPmAltConSet</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146738"><span class="hs-identifier hs-var">neg</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146741"><span class="hs-identifier hs-var">nalt</span></a></span><span>
</span><span id="line-931"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146716"><span class="annot"><span class="annottext">vi_ext :: VarInfo
</span><a href="#local-6989586621681146716"><span class="hs-identifier hs-var hs-var">vi_ext</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146740"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">vi_neg :: PmAltConSet
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_neg"><span class="hs-identifier hs-var">vi_neg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146719"><span class="hs-identifier hs-var">neg'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-932"></span><span>  </span><span class="hs-comment">-- 3. Make sure there's at least one other possible constructor</span><span>
</span><span id="line-933"></span><span>  </span><span id="local-6989586621681146715"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146715"><span class="hs-identifier hs-var">vi'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146741"><span class="hs-identifier hs-var">nalt</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-934"></span><span>    </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-type">PmAltConLike</span></a></span><span> </span><span id="local-6989586621681146714"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146714"><span class="hs-identifier hs-var">cl</span></a></span></span><span>
</span><span id="line-935"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo) -&gt; MaybeT DsM VarInfo
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; VarInfo -&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ensureInhabited"><span class="hs-identifier hs-var">ensureInhabited</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146745"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146716"><span class="hs-identifier hs-var">vi_ext</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">vi_cache :: PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_cache"><span class="hs-identifier hs-var">vi_cache</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConLike -&gt; PossibleMatches -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#markMatched"><span class="hs-identifier hs-var">markMatched</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146714"><span class="hs-identifier hs-var">cl</span></a></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="#local-6989586621681146737"><span class="hs-identifier hs-var">pm</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-936"></span><span>    </span><span class="annot"><span class="annottext">PmAltCon
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; MaybeT DsM VarInfo
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146716"><span class="hs-identifier hs-var">vi_ext</span></a></span><span>
</span><span id="line-937"></span><span>  </span><span class="annot"><span class="annottext">Delta -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146745"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; CoreMap Id -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-var">TmSt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; VarInfo -&gt; SharedDIdEnv VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; a -&gt; SharedDIdEnv a
</span><a href="GHC.HsToCore.PmCheck.Types.html#setEntrySDIE"><span class="hs-identifier hs-var">setEntrySDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146744"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146742"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146715"><span class="hs-identifier hs-var">vi'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146743"><span class="hs-identifier hs-var">reps</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-938"></span><span>
</span><span id="line-939"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#hasRequiredTheta"><span class="hs-identifier hs-type">hasRequiredTheta</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-940"></span><span id="hasRequiredTheta"><span class="annot"><span class="annottext">hasRequiredTheta :: PmAltCon -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#hasRequiredTheta"><span class="hs-identifier hs-var hs-var">hasRequiredTheta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-type">PmAltConLike</span></a></span><span> </span><span id="local-6989586621681146710"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146710"><span class="hs-identifier hs-var">cl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Bool
forall a. [a] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#notNull"><span class="hs-identifier hs-var">notNull</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146708"><span class="hs-identifier hs-var">req_theta</span></a></span><span>
</span><span id="line-941"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-942"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[EqSpec]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681146708"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146708"><span class="hs-identifier hs-var">req_theta</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Scaled Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConLike
-&gt; ([Id], [Id], [EqSpec], [Type], [Type], [Scaled Type], Type)
</span><a href="GHC.Core.ConLike.html#conLikeFullSig"><span class="hs-identifier hs-var">conLikeFullSig</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146710"><span class="hs-identifier hs-var">cl</span></a></span><span>
</span><span id="line-943"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#hasRequiredTheta"><span class="hs-identifier hs-var">hasRequiredTheta</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-944"></span><span>
</span><span id="line-945"></span><span class="hs-comment">{- Note [Completeness checking with required Thetas]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider the situation in #11224

    import Text.Read (readMaybe)
    pattern PRead :: Read a =&gt; () =&gt; a -&gt; String
    pattern PRead x &lt;- (readMaybe -&gt; Just x)
    f :: String -&gt; Int
    f (PRead x)  = x
    f (PRead xs) = length xs
    f _          = 0

Is the first match exhaustive on the PRead synonym? Should the second line thus
deemed redundant? The answer is, of course, No! The required theta is like a
hidden parameter which must be supplied at the pattern match site, so PRead
is much more like a view pattern (where behavior depends on the particular value
passed in).
The simple solution here is to forget in 'addNotConCt' that we matched
on synonyms with a required Theta like @PRead@, so that subsequent matches on
the same constructor are never flagged as redundant. The consequence is that
we no longer detect the actually redundant match in

    g :: String -&gt; Int
    g (PRead x) = x
    g (PRead y) = y -- redundant!
    g _         = 0

But that's a small price to pay, compared to the proper solution here involving
storing required arguments along with the PmAltConLike in 'vi_neg'.
-}</span><span>
</span><span id="line-975"></span><span>
</span><span id="line-976"></span><span class="hs-comment">-- | Guess the universal argument types of a ConLike from an instantiation of</span><span>
</span><span id="line-977"></span><span class="hs-comment">-- its result type. Rather easy for DataCons, but not so much for PatSynCons.</span><span>
</span><span id="line-978"></span><span class="hs-comment">-- See Note [Pattern synonym result type] in &quot;GHC.Core.PatSyn&quot;.</span><span>
</span><span id="line-979"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#guessConLikeUnivTyArgsFromResTy"><span class="hs-identifier hs-type">guessConLikeUnivTyArgsFromResTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInstEnvs"><span class="hs-identifier hs-type">FamInstEnvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-980"></span><span id="guessConLikeUnivTyArgsFromResTy"><span class="annot"><span class="annottext">guessConLikeUnivTyArgsFromResTy :: FamInstEnvs -&gt; Type -&gt; ConLike -&gt; Maybe [Type]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#guessConLikeUnivTyArgsFromResTy"><span class="hs-identifier hs-var hs-var">guessConLikeUnivTyArgsFromResTy</span></a></span></span><span> </span><span id="local-6989586621681146706"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146706"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681146705"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146705"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-981"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621681146704"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146704"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146703"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146703"><span class="hs-identifier hs-var">tc_args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146705"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-982"></span><span>  </span><span class="hs-comment">-- Consider data families: In case of a DataCon, we need to translate to</span><span>
</span><span id="line-983"></span><span>  </span><span class="hs-comment">-- the representation TyCon. For PatSyns, they are relative to the data</span><span>
</span><span id="line-984"></span><span>  </span><span class="hs-comment">-- family TyCon, so we don't need to translate them.</span><span>
</span><span id="line-985"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146702"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146702"><span class="hs-identifier hs-var">tc_args'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs -&gt; TyCon -&gt; [Type] -&gt; (TyCon, [Type], Coercion)
</span><a href="GHC.Tc.Instance.Family.html#tcLookupDataFamInst"><span class="hs-identifier hs-var">tcLookupDataFamInst</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146706"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146704"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146703"><span class="hs-identifier hs-var">tc_args</span></a></span><span>
</span><span id="line-986"></span><span>  </span><span class="annot"><span class="annottext">[Type] -&gt; Maybe [Type]
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146702"><span class="hs-identifier hs-var">tc_args'</span></a></span><span>
</span><span id="line-987"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#guessConLikeUnivTyArgsFromResTy"><span class="hs-identifier hs-var">guessConLikeUnivTyArgsFromResTy</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><span class="hs-identifier">_</span></span><span>   </span><span id="local-6989586621681146701"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146701"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#PatSynCon"><span class="hs-identifier hs-type">PatSynCon</span></a></span><span> </span><span id="local-6989586621681146699"><span class="annot"><span class="annottext">PatSyn
</span><a href="#local-6989586621681146699"><span class="hs-identifier hs-var">ps</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-988"></span><span>  </span><span class="hs-comment">-- We are successful if we managed to instantiate *every* univ_tv of con.</span><span>
</span><span id="line-989"></span><span>  </span><span class="hs-comment">-- This is difficult and bound to fail in some cases, see</span><span>
</span><span id="line-990"></span><span>  </span><span class="hs-comment">-- Note [Pattern synonym result type] in GHC.Core.PatSyn. So we just try our best</span><span>
</span><span id="line-991"></span><span>  </span><span class="hs-comment">-- here and be sure to return an instantiation when we can substitute every</span><span>
</span><span id="line-992"></span><span>  </span><span class="hs-comment">-- universally quantified type variable.</span><span>
</span><span id="line-993"></span><span>  </span><span class="hs-comment">-- We *could* instantiate all the other univ_tvs just to fresh variables, I</span><span>
</span><span id="line-994"></span><span>  </span><span class="hs-comment">-- suppose, but that means we get weird field types for which we don't know</span><span>
</span><span id="line-995"></span><span>  </span><span class="hs-comment">-- anything. So we prefer to keep it simple here.</span><span>
</span><span id="line-996"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146698"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146698"><span class="hs-identifier hs-var">univ_tvs</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Scaled Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681146697"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146697"><span class="hs-identifier hs-var">con_res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PatSyn -&gt; ([Id], [Type], [Id], [Type], [Scaled Type], Type)
</span><a href="GHC.Core.PatSyn.html#patSynSig"><span class="hs-identifier hs-var">patSynSig</span></a></span><span> </span><span class="annot"><span class="annottext">PatSyn
</span><a href="#local-6989586621681146699"><span class="hs-identifier hs-var">ps</span></a></span><span>
</span><span id="line-997"></span><span>  </span><span id="local-6989586621681146695"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681146695"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTy"><span class="hs-identifier hs-var">tcMatchTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146697"><span class="hs-identifier hs-var">con_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146701"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-998"></span><span>  </span><span class="annot"><span class="annottext">(Id -&gt; Maybe Type) -&gt; [Id] -&gt; Maybe [Type]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Id -&gt; Maybe Type
</span><a href="GHC.Core.TyCo.Subst.html#lookupTyVar"><span class="hs-identifier hs-var">lookupTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681146695"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146698"><span class="hs-identifier hs-var">univ_tvs</span></a></span><span>
</span><span id="line-999"></span><span>
</span><span id="line-1000"></span><span class="hs-comment">-- | Adds the constraint @x ~/ &#8869;@ to 'Delta'.</span><span>
</span><span id="line-1001"></span><span class="hs-comment">--</span><span>
</span><span id="line-1002"></span><span class="hs-comment">-- But doesn't really commit to upholding that constraint in the future. This</span><span>
</span><span id="line-1003"></span><span class="hs-comment">-- will be rectified in a follow-up patch. The status quo should work good</span><span>
</span><span id="line-1004"></span><span class="hs-comment">-- enough for now.</span><span>
</span><span id="line-1005"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addNotBotCt"><span class="hs-identifier hs-type">addNotBotCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-1006"></span><span id="addNotBotCt"><span class="annot"><span class="annottext">addNotBotCt :: Delta -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addNotBotCt"><span class="hs-identifier hs-var hs-var">addNotBotCt</span></a></span></span><span> </span><span id="local-6989586621681146693"><span class="annot"><span class="annottext">delta :: Delta
</span><a href="#local-6989586621681146693"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span> </span><span id="local-6989586621681146692"><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146692"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681146691"><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146691"><span class="hs-identifier hs-var">reps</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146690"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146690"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1007"></span><span>  </span><span id="local-6989586621681146689"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146689"><span class="hs-identifier hs-var">vi</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM VarInfo -&gt; MaybeT DsM VarInfo
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(DsM VarInfo -&gt; MaybeT DsM VarInfo)
-&gt; DsM VarInfo -&gt; MaybeT DsM VarInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; DsM VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#initLookupVarInfo"><span class="hs-identifier hs-var">initLookupVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146693"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146690"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-1008"></span><span>  </span><span id="local-6989586621681146688"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146688"><span class="hs-identifier hs-var">vi'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo) -&gt; MaybeT DsM VarInfo
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo)
 -&gt; MaybeT DsM VarInfo)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo)
-&gt; MaybeT DsM VarInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; VarInfo -&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ensureInhabited"><span class="hs-identifier hs-var">ensureInhabited</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146693"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146689"><span class="hs-identifier hs-var">vi</span></a></span><span>
</span><span id="line-1009"></span><span>  </span><span class="hs-comment">-- vi' has probably constructed and then thinned out some PossibleMatches.</span><span>
</span><span id="line-1010"></span><span>  </span><span class="hs-comment">-- We want to cache that work</span><span>
</span><span id="line-1011"></span><span>  </span><span class="annot"><span class="annottext">Delta -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146693"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; CoreMap Id -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-var">TmSt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; VarInfo -&gt; SharedDIdEnv VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; a -&gt; SharedDIdEnv a
</span><a href="GHC.HsToCore.PmCheck.Types.html#setEntrySDIE"><span class="hs-identifier hs-var">setEntrySDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146692"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146690"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146688"><span class="hs-identifier hs-var">vi'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146691"><span class="hs-identifier hs-var">reps</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-1012"></span><span>
</span><span id="line-1013"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#ensureInhabited"><span class="hs-identifier hs-type">ensureInhabited</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VarInfo"><span class="hs-identifier hs-type">VarInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VarInfo"><span class="hs-identifier hs-type">VarInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1014"></span><span>   </span><span class="hs-comment">-- Returns (Just vi) if at least one member of each ConLike in the COMPLETE</span><span>
</span><span id="line-1015"></span><span>   </span><span class="hs-comment">-- set satisfies the oracle</span><span>
</span><span id="line-1016"></span><span>   </span><span class="hs-comment">--</span><span>
</span><span id="line-1017"></span><span>   </span><span class="hs-comment">-- Internally uses and updates the ConLikeSets in vi_cache.</span><span>
</span><span id="line-1018"></span><span>   </span><span class="hs-comment">--</span><span>
</span><span id="line-1019"></span><span>   </span><span class="hs-comment">-- NB: Does /not/ filter each ConLikeSet with the oracle; members may</span><span>
</span><span id="line-1020"></span><span>   </span><span class="hs-comment">--     remain that do not statisfy it.  This lazy approach just</span><span>
</span><span id="line-1021"></span><span>   </span><span class="hs-comment">--     avoids doing unnecessary work.</span><span>
</span><span id="line-1022"></span><span id="ensureInhabited"><span class="annot"><span class="annottext">ensureInhabited :: Delta -&gt; VarInfo -&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ensureInhabited"><span class="hs-identifier hs-var hs-var">ensureInhabited</span></a></span></span><span> </span><span id="local-6989586621681146687"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146687"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span id="local-6989586621681146686"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146686"><span class="hs-identifier hs-var">vi</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(PossibleMatches -&gt; VarInfo)
-&gt; Maybe PossibleMatches -&gt; Maybe VarInfo
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarInfo -&gt; PossibleMatches -&gt; VarInfo
</span><a href="#local-6989586621681146685"><span class="hs-identifier hs-var">set_cache</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146686"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Maybe PossibleMatches -&gt; Maybe VarInfo)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe PossibleMatches)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe PossibleMatches)
</span><a href="#local-6989586621681146684"><span class="hs-identifier hs-var">test</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarInfo -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_cache"><span class="hs-identifier hs-var hs-var">vi_cache</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146686"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- This would be much less tedious with lenses</span><span>
</span><span id="line-1023"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1024"></span><span>    </span><span id="local-6989586621681146685"><span class="annot"><span class="annottext">set_cache :: VarInfo -&gt; PossibleMatches -&gt; VarInfo
</span><a href="#local-6989586621681146685"><span class="hs-identifier hs-var hs-var">set_cache</span></a></span></span><span> </span><span id="local-6989586621681146683"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146683"><span class="hs-identifier hs-var">vi</span></a></span></span><span> </span><span id="local-6989586621681146682"><span class="annot"><span class="annottext">PossibleMatches
</span><a href="#local-6989586621681146682"><span class="hs-identifier hs-var">cache</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146683"><span class="hs-identifier hs-var">vi</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">vi_cache :: PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_cache"><span class="hs-identifier hs-var">vi_cache</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="#local-6989586621681146682"><span class="hs-identifier hs-var">cache</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1025"></span><span>
</span><span id="line-1026"></span><span>    </span><span id="local-6989586621681146684"><span class="annot"><span class="annottext">test :: PossibleMatches
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe PossibleMatches)
</span><a href="#local-6989586621681146684"><span class="hs-identifier hs-var hs-var">test</span></a></span></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#NoPM"><span class="hs-identifier hs-var">NoPM</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe PossibleMatches
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe PossibleMatches)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PossibleMatches -&gt; Maybe PossibleMatches
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#NoPM"><span class="hs-identifier hs-var">NoPM</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1027"></span><span>    </span><span class="annot"><a href="#local-6989586621681146684"><span class="hs-identifier hs-var">test</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PM"><span class="hs-identifier hs-type">PM</span></a></span><span> </span><span id="local-6989586621681146674"><span class="annot"><span class="annottext">NonEmpty ConLikeSet
</span><a href="#local-6989586621681146674"><span class="hs-identifier hs-var">ms</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM PossibleMatches
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe PossibleMatches)
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NonEmpty ConLikeSet -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#PM"><span class="hs-identifier hs-var">PM</span></a></span><span> </span><span class="annot"><span class="annottext">(NonEmpty ConLikeSet -&gt; PossibleMatches)
-&gt; MaybeT DsM (NonEmpty ConLikeSet) -&gt; MaybeT DsM PossibleMatches
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(ConLikeSet -&gt; MaybeT DsM ConLikeSet)
-&gt; NonEmpty ConLikeSet -&gt; MaybeT DsM (NonEmpty ConLikeSet)
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">ConLikeSet -&gt; MaybeT DsM ConLikeSet
</span><a href="#local-6989586621681146673"><span class="hs-identifier hs-var">one_set</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty ConLikeSet
</span><a href="#local-6989586621681146674"><span class="hs-identifier hs-var">ms</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1028"></span><span>
</span><span id="line-1029"></span><span>    </span><span id="local-6989586621681146673"><span class="annot"><span class="annottext">one_set :: ConLikeSet -&gt; MaybeT DsM ConLikeSet
</span><a href="#local-6989586621681146673"><span class="hs-identifier hs-var hs-var">one_set</span></a></span></span><span> </span><span id="local-6989586621681146672"><span class="annot"><span class="annottext">ConLikeSet
</span><a href="#local-6989586621681146672"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConLikeSet -&gt; [ConLike] -&gt; MaybeT DsM ConLikeSet
</span><a href="#local-6989586621681146671"><span class="hs-identifier hs-var">find_one_inh</span></a></span><span> </span><span class="annot"><span class="annottext">ConLikeSet
</span><a href="#local-6989586621681146672"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLikeSet -&gt; [ConLike]
forall a. UniqDSet a -&gt; [a]
</span><a href="GHC.Types.Unique.DSet.html#uniqDSetToList"><span class="hs-identifier hs-var">uniqDSetToList</span></a></span><span> </span><span class="annot"><span class="annottext">ConLikeSet
</span><a href="#local-6989586621681146672"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1030"></span><span>
</span><span id="line-1031"></span><span>    </span><span class="annot"><a href="#local-6989586621681146671"><span class="hs-identifier hs-type">find_one_inh</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#ConLikeSet"><span class="hs-identifier hs-type">ConLikeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#ConLikeSet"><span class="hs-identifier hs-type">ConLikeSet</span></a></span><span>
</span><span id="line-1032"></span><span>    </span><span class="hs-comment">-- (find_one_inh cs cls) iterates over cls, deleting from cs</span><span>
</span><span id="line-1033"></span><span>    </span><span class="hs-comment">-- any uninhabited elements of cls.  Stop (returning Just cs)</span><span>
</span><span id="line-1034"></span><span>    </span><span class="hs-comment">-- when you see an inhabited element; return Nothing if all</span><span>
</span><span id="line-1035"></span><span>    </span><span class="hs-comment">-- are uninhabited</span><span>
</span><span id="line-1036"></span><span>    </span><span id="local-6989586621681146671"><span class="annot"><span class="annottext">find_one_inh :: ConLikeSet -&gt; [ConLike] -&gt; MaybeT DsM ConLikeSet
</span><a href="#local-6989586621681146671"><span class="hs-identifier hs-var hs-var">find_one_inh</span></a></span></span><span> </span><span class="annot"><span class="annottext">ConLikeSet
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM ConLikeSet
forall (m :: * -&gt; *) a. MonadPlus m =&gt; m a
</span><a href="../../base/src/GHC.Base.html#mzero"><span class="hs-identifier hs-var">mzero</span></a></span><span>
</span><span id="line-1037"></span><span>    </span><span class="annot"><a href="#local-6989586621681146671"><span class="hs-identifier hs-var">find_one_inh</span></a></span><span> </span><span id="local-6989586621681146669"><span class="annot"><span class="annottext">ConLikeSet
</span><a href="#local-6989586621681146669"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146668"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146668"><span class="hs-identifier hs-var">con</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681146667"><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681146667"><span class="hs-identifier hs-var">cons</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) Bool -&gt; MaybeT DsM Bool
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="#local-6989586621681146666"><span class="hs-identifier hs-var">inh_test</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146668"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM Bool
-&gt; (Bool -&gt; MaybeT DsM ConLikeSet) -&gt; MaybeT DsM ConLikeSet
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-glyph">case</span><span>
</span><span id="line-1038"></span><span>      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ConLikeSet -&gt; MaybeT DsM ConLikeSet
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">ConLikeSet
</span><a href="#local-6989586621681146669"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-1039"></span><span>      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ConLikeSet -&gt; [ConLike] -&gt; MaybeT DsM ConLikeSet
</span><a href="#local-6989586621681146671"><span class="hs-identifier hs-var">find_one_inh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLikeSet -&gt; ConLike -&gt; ConLikeSet
forall a. Uniquable a =&gt; UniqDSet a -&gt; a -&gt; UniqDSet a
</span><a href="GHC.Types.Unique.DSet.html#delOneFromUniqDSet"><span class="hs-identifier hs-var">delOneFromUniqDSet</span></a></span><span> </span><span class="annot"><span class="annottext">ConLikeSet
</span><a href="#local-6989586621681146669"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146668"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681146667"><span class="hs-identifier hs-var">cons</span></a></span><span>
</span><span id="line-1040"></span><span>
</span><span id="line-1041"></span><span>    </span><span class="annot"><a href="#local-6989586621681146666"><span class="hs-identifier hs-type">inh_test</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1042"></span><span>    </span><span class="hs-comment">-- @inh_test K@ Returns False if a non-bottom value @v::ty@ cannot possibly</span><span>
</span><span id="line-1043"></span><span>    </span><span class="hs-comment">-- be of form @K _ _ _@. Returning True is always sound.</span><span>
</span><span id="line-1044"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-1045"></span><span>    </span><span class="hs-comment">-- It's like 'DataCon.dataConCannotMatch', but more clever because it takes</span><span>
</span><span id="line-1046"></span><span>    </span><span class="hs-comment">-- the facts in Delta into account.</span><span>
</span><span id="line-1047"></span><span>    </span><span id="local-6989586621681146666"><span class="annot"><span class="annottext">inh_test :: ConLike -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="#local-6989586621681146666"><span class="hs-identifier hs-var hs-var">inh_test</span></a></span></span><span> </span><span id="local-6989586621681146665"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146665"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1048"></span><span>      </span><span id="local-6989586621681146664"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146664"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM FamInstEnvs
</span><a href="GHC.HsToCore.Monad.html#dsGetFamInstEnvs"><span class="hs-identifier hs-var">dsGetFamInstEnvs</span></a></span><span>
</span><span id="line-1049"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs -&gt; Type -&gt; ConLike -&gt; Maybe [Type]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#guessConLikeUnivTyArgsFromResTy"><span class="hs-identifier hs-var">guessConLikeUnivTyArgsFromResTy</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146664"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarInfo -&gt; Type
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_ty"><span class="hs-identifier hs-var hs-var">vi_ty</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146686"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146665"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1050"></span><span>        </span><span class="annot"><span class="annottext">Maybe [Type]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- be conservative about this</span><span>
</span><span id="line-1051"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146663"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146663"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1052"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621681146662"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146662"><span class="hs-identifier hs-var">_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146661"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146661"><span class="hs-identifier hs-var">_vars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146660"><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146660"><span class="hs-identifier hs-var">ty_cs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146659"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146659"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; ConLike -&gt; DsM ([Id], [Id], Bag Type, [Type])
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkOneConFull"><span class="hs-identifier hs-var">mkOneConFull</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146663"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146665"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-1053"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-var">tracePm</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;inh_test&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146665"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146660"><span class="hs-identifier hs-var">ty_cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1054"></span><span>          </span><span class="hs-comment">-- No need to run the term oracle compared to pmIsSatisfiable</span><span>
</span><span id="line-1055"></span><span>          </span><span class="annot"><span class="annottext">(Maybe Delta -&gt; Bool)
-&gt; DsM (Maybe Delta) -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Delta -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">(DsM (Maybe Delta) -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool)
-&gt; (SatisfiabilityCheck -&gt; DsM (Maybe Delta))
-&gt; SatisfiabilityCheck
-&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; SatisfiabilityCheck -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#runSatisfiabilityCheck"><span class="hs-identifier hs-var">runSatisfiabilityCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146687"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">(SatisfiabilityCheck -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool)
-&gt; SatisfiabilityCheck -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SatisfiabilityCheck] -&gt; SatisfiabilityCheck
forall a. Monoid a =&gt; [a] -&gt; a
</span><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var">mconcat</span></a></span><span>
</span><span id="line-1056"></span><span>            </span><span class="hs-comment">-- Important to pass False to tyIsSatisfiable here, so that we won't</span><span>
</span><span id="line-1057"></span><span>            </span><span class="hs-comment">-- recursively call ensureAllPossibleMatchesInhabited, leading to an</span><span>
</span><span id="line-1058"></span><span>            </span><span class="hs-comment">-- endless recursion.</span><span>
</span><span id="line-1059"></span><span>            </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bag Type -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tyIsSatisfiable"><span class="hs-identifier hs-var">tyIsSatisfiable</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146660"><span class="hs-identifier hs-var">ty_cs</span></a></span><span>
</span><span id="line-1060"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; [Type] -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tysAreNonVoid"><span class="hs-identifier hs-var">tysAreNonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="GHC.Core.TyCon.html#initRecTc"><span class="hs-identifier hs-var">initRecTc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146659"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span>
</span><span id="line-1061"></span><span>            </span><span class="hs-special">]</span><span>
</span><span id="line-1062"></span><span>
</span><span id="line-1063"></span><span class="hs-comment">-- | Checks if every 'VarInfo' in the term oracle has still an inhabited</span><span>
</span><span id="line-1064"></span><span class="hs-comment">-- 'vi_cache', considering the current type information in 'Delta'.</span><span>
</span><span id="line-1065"></span><span class="hs-comment">-- This check is necessary after having matched on a GADT con to weed out</span><span>
</span><span id="line-1066"></span><span class="hs-comment">-- impossible matches.</span><span>
</span><span id="line-1067"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#ensureAllPossibleMatchesInhabited"><span class="hs-identifier hs-type">ensureAllPossibleMatchesInhabited</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1068"></span><span id="ensureAllPossibleMatchesInhabited"><span class="annot"><span class="annottext">ensureAllPossibleMatchesInhabited :: Delta -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ensureAllPossibleMatchesInhabited"><span class="hs-identifier hs-var hs-var">ensureAllPossibleMatchesInhabited</span></a></span></span><span> </span><span id="local-6989586621681146657"><span class="annot"><span class="annottext">delta :: Delta
</span><a href="#local-6989586621681146657"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span> </span><span id="local-6989586621681146656"><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146656"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681146655"><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146655"><span class="hs-identifier hs-var">reps</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1069"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM Delta -&gt; DsM (Maybe Delta)
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; SharedDIdEnv VarInfo -&gt; Delta
</span><a href="#local-6989586621681146654"><span class="hs-identifier hs-var">set_tm_cs_env</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146657"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">(SharedDIdEnv VarInfo -&gt; Delta)
-&gt; MaybeT DsM (SharedDIdEnv VarInfo) -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(VarInfo -&gt; MaybeT DsM VarInfo)
-&gt; SharedDIdEnv VarInfo -&gt; MaybeT DsM (SharedDIdEnv VarInfo)
forall a b (f :: * -&gt; *).
Applicative f =&gt;
(a -&gt; f b) -&gt; SharedDIdEnv a -&gt; f (SharedDIdEnv b)
</span><a href="GHC.HsToCore.PmCheck.Types.html#traverseSDIE"><span class="hs-identifier hs-var">traverseSDIE</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; MaybeT DsM VarInfo
</span><a href="#local-6989586621681146652"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146656"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1070"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1071"></span><span>    </span><span id="local-6989586621681146654"><span class="annot"><span class="annottext">set_tm_cs_env :: Delta -&gt; SharedDIdEnv VarInfo -&gt; Delta
</span><a href="#local-6989586621681146654"><span class="hs-identifier hs-var hs-var">set_tm_cs_env</span></a></span></span><span> </span><span id="local-6989586621681146651"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146651"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span id="local-6989586621681146650"><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146650"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146651"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; CoreMap Id -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-var">TmSt</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146650"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146655"><span class="hs-identifier hs-var">reps</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1072"></span><span>    </span><span id="local-6989586621681146652"><span class="annot"><span class="annottext">go :: VarInfo -&gt; MaybeT DsM VarInfo
</span><a href="#local-6989586621681146652"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681146649"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146649"><span class="hs-identifier hs-var">vi</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo) -&gt; MaybeT DsM VarInfo
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; VarInfo -&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe VarInfo)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ensureInhabited"><span class="hs-identifier hs-var">ensureInhabited</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146657"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146649"><span class="hs-identifier hs-var">vi</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1073"></span><span>
</span><span id="line-1074"></span><span class="hs-comment">--------------------------------------</span><span>
</span><span id="line-1075"></span><span class="hs-comment">-- * Term oracle unification procedure</span><span>
</span><span id="line-1076"></span><span>
</span><span id="line-1077"></span><span class="hs-comment">-- | Adds a @x ~ y@ constraint by trying to unify two 'Id's and record the</span><span>
</span><span id="line-1078"></span><span class="hs-comment">-- gained knowledge in 'Delta'.</span><span>
</span><span id="line-1079"></span><span class="hs-comment">--</span><span>
</span><span id="line-1080"></span><span class="hs-comment">-- Returns @Nothing@ when there's a contradiction. Returns @Just delta@</span><span>
</span><span id="line-1081"></span><span class="hs-comment">-- when the constraint was compatible with prior facts, in which case @delta@</span><span>
</span><span id="line-1082"></span><span class="hs-comment">-- has integrated the knowledge from the equality constraint.</span><span>
</span><span id="line-1083"></span><span class="hs-comment">--</span><span>
</span><span id="line-1084"></span><span class="hs-comment">-- See Note [TmState invariants].</span><span>
</span><span id="line-1085"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addVarCt"><span class="hs-identifier hs-type">addVarCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-1086"></span><span id="addVarCt"><span class="annot"><span class="annottext">addVarCt :: Delta -&gt; Id -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addVarCt"><span class="hs-identifier hs-var hs-var">addVarCt</span></a></span></span><span> </span><span id="local-6989586621681146648"><span class="annot"><span class="annottext">delta :: Delta
</span><a href="#local-6989586621681146648"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span> </span><span id="local-6989586621681146647"><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146647"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146646"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146646"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146645"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146645"><span class="hs-identifier hs-var">y</span></a></span></span><span>
</span><span id="line-1087"></span><span>  </span><span class="hs-comment">-- It's important that we never @equate@ two variables of the same equivalence</span><span>
</span><span id="line-1088"></span><span>  </span><span class="hs-comment">-- class, otherwise we might get cyclic substitutions.</span><span>
</span><span id="line-1089"></span><span>  </span><span class="hs-comment">-- Cf. 'extendSubstAndSolve' and</span><span>
</span><span id="line-1090"></span><span>  </span><span class="hs-comment">-- @testsuite/tests/pmcheck/should_compile/CyclicSubst.hs@.</span><span>
</span><span id="line-1091"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; Id -&gt; Bool
forall a. SharedDIdEnv a -&gt; Id -&gt; Id -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Types.html#sameRepresentativeSDIE"><span class="hs-identifier hs-var">sameRepresentativeSDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146647"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146646"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146645"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146648"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-1092"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#equate"><span class="hs-identifier hs-var">equate</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146648"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146646"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146645"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-1093"></span><span>
</span><span id="line-1094"></span><span class="hs-comment">-- | @equate ts@(TmSt env) x y@ merges the equivalence classes of @x@ and @y@ by</span><span>
</span><span id="line-1095"></span><span class="hs-comment">-- adding an indirection to the environment.</span><span>
</span><span id="line-1096"></span><span class="hs-comment">-- Makes sure that the positive and negative facts of @x@ and @y@ are</span><span>
</span><span id="line-1097"></span><span class="hs-comment">-- compatible.</span><span>
</span><span id="line-1098"></span><span class="hs-comment">-- Preconditions: @not (sameRepresentativeSDIE env x y)@</span><span>
</span><span id="line-1099"></span><span class="hs-comment">--</span><span>
</span><span id="line-1100"></span><span class="hs-comment">-- See Note [TmState invariants].</span><span>
</span><span id="line-1101"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#equate"><span class="hs-identifier hs-type">equate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-1102"></span><span id="equate"><span class="annot"><span class="annottext">equate :: Delta -&gt; Id -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#equate"><span class="hs-identifier hs-var hs-var">equate</span></a></span></span><span> </span><span id="local-6989586621681146642"><span class="annot"><span class="annottext">delta :: Delta
</span><a href="#local-6989586621681146642"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span> </span><span id="local-6989586621681146641"><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146641"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681146640"><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146640"><span class="hs-identifier hs-var">reps</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146639"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146639"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146638"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146638"><span class="hs-identifier hs-var">y</span></a></span></span><span>
</span><span id="line-1103"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">sameRepresentativeSDIE</span><span> </span><span class="hs-identifier">env</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1104"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; Maybe VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.HsToCore.PmCheck.Types.html#lookupSDIE"><span class="hs-identifier hs-var">lookupSDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146641"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146639"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; Maybe VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.HsToCore.PmCheck.Types.html#lookupSDIE"><span class="hs-identifier hs-var">lookupSDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146641"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146638"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1105"></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe VarInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe VarInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146642"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; CoreMap Id -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-var">TmSt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; Id -&gt; SharedDIdEnv VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; Id -&gt; SharedDIdEnv a
</span><a href="GHC.HsToCore.PmCheck.Types.html#setIndirectSDIE"><span class="hs-identifier hs-var">setIndirectSDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146641"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146639"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146638"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146640"><span class="hs-identifier hs-var">reps</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1106"></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe VarInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe VarInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146642"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; CoreMap Id -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-var">TmSt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; Id -&gt; SharedDIdEnv VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; Id -&gt; SharedDIdEnv a
</span><a href="GHC.HsToCore.PmCheck.Types.html#setIndirectSDIE"><span class="hs-identifier hs-var">setIndirectSDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146641"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146638"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146639"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146640"><span class="hs-identifier hs-var">reps</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1107"></span><span>      </span><span class="hs-comment">-- Merge the info we have for x into the info for y</span><span>
</span><span id="line-1108"></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146635"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146635"><span class="hs-identifier hs-var">vi_x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146634"><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146634"><span class="hs-identifier hs-var">vi_y</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1109"></span><span>        </span><span class="hs-comment">-- This assert will probably trigger at some point...</span><span>
</span><span id="line-1110"></span><span>        </span><span class="hs-comment">-- We should decide how to break the tie</span><span>
</span><span id="line-1111"></span><span>        </span><span class="hs-identifier">MASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">vi_ty</span><span> </span><span class="hs-identifier">vi_x</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">eqType</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">vi_ty</span><span> </span><span class="hs-identifier">vi_y</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;Not same type&quot;</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1112"></span><span>        </span><span class="hs-comment">-- First assume that x and y are in the same equivalence class</span><span>
</span><span id="line-1113"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146632"><span class="annot"><span class="annottext">env_ind :: SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146632"><span class="hs-identifier hs-var hs-var">env_ind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; Id -&gt; SharedDIdEnv VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; Id -&gt; SharedDIdEnv a
</span><a href="GHC.HsToCore.PmCheck.Types.html#setIndirectSDIE"><span class="hs-identifier hs-var">setIndirectSDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146641"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146639"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146638"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-1114"></span><span>        </span><span class="hs-comment">-- Then sum up the refinement counters</span><span>
</span><span id="line-1115"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146631"><span class="annot"><span class="annottext">env_refs :: SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146631"><span class="hs-identifier hs-var hs-var">env_refs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; VarInfo -&gt; SharedDIdEnv VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; a -&gt; SharedDIdEnv a
</span><a href="GHC.HsToCore.PmCheck.Types.html#setEntrySDIE"><span class="hs-identifier hs-var">setEntrySDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146632"><span class="hs-identifier hs-var">env_ind</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146638"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146634"><span class="hs-identifier hs-var">vi_y</span></a></span><span>
</span><span id="line-1116"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146630"><span class="annot"><span class="annottext">delta_refs :: Delta
</span><a href="#local-6989586621681146630"><span class="hs-identifier hs-var hs-var">delta_refs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146642"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; CoreMap Id -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-var">TmSt</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146631"><span class="hs-identifier hs-var">env_refs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146640"><span class="hs-identifier hs-var">reps</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1117"></span><span>        </span><span class="hs-comment">-- and then gradually merge every positive fact we have on x into y</span><span>
</span><span id="line-1118"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146629"><span class="annot"><span class="annottext">add_fact :: Delta -&gt; (PmAltCon, [Id], [Id]) -&gt; MaybeT DsM Delta
</span><a href="#local-6989586621681146629"><span class="hs-identifier hs-var hs-var">add_fact</span></a></span></span><span> </span><span id="local-6989586621681146628"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146628"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146627"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146627"><span class="hs-identifier hs-var">cl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146626"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146626"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146625"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146625"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addConCt"><span class="hs-identifier hs-var">addConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146628"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146638"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146627"><span class="hs-identifier hs-var">cl</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146626"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146625"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1119"></span><span>        </span><span id="local-6989586621681146624"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146624"><span class="hs-identifier hs-var">delta_pos</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; (PmAltCon, [Id], [Id]) -&gt; MaybeT DsM Delta)
-&gt; Delta -&gt; [(PmAltCon, [Id], [Id])] -&gt; MaybeT DsM Delta
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; (PmAltCon, [Id], [Id]) -&gt; MaybeT DsM Delta
</span><a href="#local-6989586621681146629"><span class="hs-identifier hs-var">add_fact</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146630"><span class="hs-identifier hs-var">delta_refs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarInfo -&gt; [(PmAltCon, [Id], [Id])]
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_pos"><span class="hs-identifier hs-var hs-var">vi_pos</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146635"><span class="hs-identifier hs-var">vi_x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1120"></span><span>        </span><span class="hs-comment">-- Do the same for negative info</span><span>
</span><span id="line-1121"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146623"><span class="annot"><span class="annottext">add_refut :: Delta -&gt; PmAltCon -&gt; MaybeT DsM Delta
</span><a href="#local-6989586621681146623"><span class="hs-identifier hs-var hs-var">add_refut</span></a></span></span><span> </span><span id="local-6989586621681146622"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146622"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span id="local-6989586621681146621"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146621"><span class="hs-identifier hs-var">nalt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; PmAltCon -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addNotConCt"><span class="hs-identifier hs-var">addNotConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146622"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146638"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146621"><span class="hs-identifier hs-var">nalt</span></a></span><span>
</span><span id="line-1122"></span><span>        </span><span id="local-6989586621681146620"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146620"><span class="hs-identifier hs-var">delta_neg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; PmAltCon -&gt; MaybeT DsM Delta)
-&gt; Delta -&gt; [PmAltCon] -&gt; MaybeT DsM Delta
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; PmAltCon -&gt; MaybeT DsM Delta
</span><a href="#local-6989586621681146623"><span class="hs-identifier hs-var">add_refut</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146624"><span class="hs-identifier hs-var">delta_pos</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmAltConSet -&gt; [PmAltCon]
</span><a href="GHC.HsToCore.PmCheck.Types.html#pmAltConSetElems"><span class="hs-identifier hs-var">pmAltConSetElems</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarInfo -&gt; PmAltConSet
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_neg"><span class="hs-identifier hs-var hs-var">vi_neg</span></a></span><span> </span><span class="annot"><span class="annottext">VarInfo
</span><a href="#local-6989586621681146635"><span class="hs-identifier hs-var">vi_x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1123"></span><span>        </span><span class="hs-comment">-- vi_cache will be updated in addNotConCt, so we are good to</span><span>
</span><span id="line-1124"></span><span>        </span><span class="hs-comment">-- go!</span><span>
</span><span id="line-1125"></span><span>        </span><span class="annot"><span class="annottext">Delta -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146620"><span class="hs-identifier hs-var">delta_neg</span></a></span><span>
</span><span id="line-1126"></span><span>
</span><span id="line-1127"></span><span class="hs-comment">-- | Add a @x ~ K tvs args ts@ constraint.</span><span>
</span><span id="line-1128"></span><span class="hs-comment">-- @addConCt x K tvs args ts@ extends the substitution with a solution</span><span>
</span><span id="line-1129"></span><span class="hs-comment">-- @x :-&gt; (K, tvs, args)@ if compatible with the negative and positive info we</span><span>
</span><span id="line-1130"></span><span class="hs-comment">-- have on @x@, reject (@Nothing@) otherwise.</span><span>
</span><span id="line-1131"></span><span class="hs-comment">--</span><span>
</span><span id="line-1132"></span><span class="hs-comment">-- See Note [TmState invariants].</span><span>
</span><span id="line-1133"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addConCt"><span class="hs-identifier hs-type">addConCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-1134"></span><span id="addConCt"><span class="annot"><span class="annottext">addConCt :: Delta -&gt; Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addConCt"><span class="hs-identifier hs-var hs-var">addConCt</span></a></span></span><span> </span><span id="local-6989586621681146619"><span class="annot"><span class="annottext">delta :: Delta
</span><a href="#local-6989586621681146619"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span> </span><span id="local-6989586621681146618"><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146618"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681146617"><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146617"><span class="hs-identifier hs-var">reps</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146616"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146616"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146615"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146615"><span class="hs-identifier hs-var">alt</span></a></span></span><span> </span><span id="local-6989586621681146614"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146614"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681146613"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146613"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1135"></span><span>  </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VI"><span class="hs-identifier hs-type">VI</span></a></span><span> </span><span id="local-6989586621681146612"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146612"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681146611"><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146611"><span class="hs-identifier hs-var">pos</span></a></span></span><span> </span><span id="local-6989586621681146610"><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146610"><span class="hs-identifier hs-var">neg</span></a></span></span><span> </span><span id="local-6989586621681146609"><span class="annot"><span class="annottext">PossibleMatches
</span><a href="#local-6989586621681146609"><span class="hs-identifier hs-var">cache</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM VarInfo -&gt; MaybeT DsM VarInfo
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; DsM VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#initLookupVarInfo"><span class="hs-identifier hs-var">initLookupVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146619"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146616"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1136"></span><span>  </span><span class="hs-comment">-- First try to refute with a negative fact</span><span>
</span><span id="line-1137"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; MaybeT DsM ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmAltCon -&gt; PmAltConSet -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Types.html#elemPmAltConSet"><span class="hs-identifier hs-var">elemPmAltConSet</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146615"><span class="hs-identifier hs-var">alt</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146610"><span class="hs-identifier hs-var">neg</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1138"></span><span>  </span><span class="hs-comment">-- Then see if any of the other solutions (remember: each of them is an</span><span>
</span><span id="line-1139"></span><span>  </span><span class="hs-comment">-- additional refinement of the possible values x could take) indicate a</span><span>
</span><span id="line-1140"></span><span>  </span><span class="hs-comment">-- contradiction</span><span>
</span><span id="line-1141"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; MaybeT DsM ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((PmAltCon, [Id], [Id]) -&gt; Bool)
-&gt; [(PmAltCon, [Id], [Id])] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmEquality -&gt; PmEquality -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">PmEquality
</span><a href="GHC.HsToCore.PmCheck.Types.html#Disjoint"><span class="hs-identifier hs-var">Disjoint</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(PmEquality -&gt; Bool)
-&gt; ((PmAltCon, [Id], [Id]) -&gt; PmEquality)
-&gt; (PmAltCon, [Id], [Id])
-&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon -&gt; PmAltCon -&gt; PmEquality
</span><a href="GHC.HsToCore.PmCheck.Types.html#eqPmAltCon"><span class="hs-identifier hs-var">eqPmAltCon</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146615"><span class="hs-identifier hs-var">alt</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon -&gt; PmEquality)
-&gt; ((PmAltCon, [Id], [Id]) -&gt; PmAltCon)
-&gt; (PmAltCon, [Id], [Id])
-&gt; PmEquality
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id]) -&gt; PmAltCon
forall a b c. (a, b, c) -&gt; a
</span><a href="GHC.Utils.Misc.html#fstOf3"><span class="hs-identifier hs-var">fstOf3</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146611"><span class="hs-identifier hs-var">pos</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1142"></span><span>  </span><span class="hs-comment">-- Now we should be good! Add (alt, tvs, args) as a possible solution, or</span><span>
</span><span id="line-1143"></span><span>  </span><span class="hs-comment">-- refine an existing one</span><span>
</span><span id="line-1144"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">((PmAltCon, [Id], [Id]) -&gt; Bool)
-&gt; [(PmAltCon, [Id], [Id])] -&gt; Maybe (PmAltCon, [Id], [Id])
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Maybe a
</span><a href="../../base/src/Data.Foldable.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmEquality -&gt; PmEquality -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">PmEquality
</span><a href="GHC.HsToCore.PmCheck.Types.html#Equal"><span class="hs-identifier hs-var">Equal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(PmEquality -&gt; Bool)
-&gt; ((PmAltCon, [Id], [Id]) -&gt; PmEquality)
-&gt; (PmAltCon, [Id], [Id])
-&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon -&gt; PmAltCon -&gt; PmEquality
</span><a href="GHC.HsToCore.PmCheck.Types.html#eqPmAltCon"><span class="hs-identifier hs-var">eqPmAltCon</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146615"><span class="hs-identifier hs-var">alt</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon -&gt; PmEquality)
-&gt; ((PmAltCon, [Id], [Id]) -&gt; PmAltCon)
-&gt; (PmAltCon, [Id], [Id])
-&gt; PmEquality
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id]) -&gt; PmAltCon
forall a b c. (a, b, c) -&gt; a
</span><a href="GHC.Utils.Misc.html#fstOf3"><span class="hs-identifier hs-var">fstOf3</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146611"><span class="hs-identifier hs-var">pos</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1145"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146605"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146605"><span class="hs-identifier hs-var">_con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146604"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146604"><span class="hs-identifier hs-var">other_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146603"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146603"><span class="hs-identifier hs-var">other_args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1146"></span><span>      </span><span class="hs-comment">-- We must unify existentially bound ty vars and arguments!</span><span>
</span><span id="line-1147"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146602"><span class="annot"><span class="annottext">ty_cts :: [PmCt]
</span><a href="#local-6989586621681146602"><span class="hs-identifier hs-var hs-var">ty_cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [PmCt]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#equateTys"><span class="hs-identifier hs-var">equateTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Type) -&gt; [Id] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146614"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Type) -&gt; [Id] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146604"><span class="hs-identifier hs-var">other_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1148"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; MaybeT DsM () -&gt; MaybeT DsM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146613"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146603"><span class="hs-identifier hs-var">other_args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(MaybeT DsM () -&gt; MaybeT DsM ()) -&gt; MaybeT DsM () -&gt; MaybeT DsM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1149"></span><span>        </span><span class="annot"><span class="annottext">DsM () -&gt; MaybeT DsM ()
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(DsM () -&gt; MaybeT DsM ()) -&gt; DsM () -&gt; MaybeT DsM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-var">tracePm</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;error&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146616"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146615"><span class="hs-identifier hs-var">alt</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146613"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146603"><span class="hs-identifier hs-var">other_args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1150"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146598"><span class="annot"><span class="annottext">tm_cts :: [PmCt]
</span><a href="#local-6989586621681146598"><span class="hs-identifier hs-var hs-var">tm_cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (Id -&gt; Id -&gt; PmCt) -&gt; [Id] -&gt; [Id] -&gt; [PmCt]
forall a b c. String -&gt; (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
</span><a href="GHC.Utils.Misc.html#zipWithEqual"><span class="hs-identifier hs-var">zipWithEqual</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;addConCt&quot;</span></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#PmVarCt"><span class="hs-identifier hs-var">PmVarCt</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146613"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146603"><span class="hs-identifier hs-var">other_args</span></a></span><span>
</span><span id="line-1151"></span><span>      </span><span class="annot"><span class="annottext">DsM (Maybe Delta) -&gt; MaybeT DsM Delta
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(DsM (Maybe Delta) -&gt; MaybeT DsM Delta)
-&gt; DsM (Maybe Delta) -&gt; MaybeT DsM Delta
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; PmCts -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addPmCts"><span class="hs-identifier hs-var">addPmCts</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146619"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[PmCt] -&gt; PmCts
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146602"><span class="hs-identifier hs-var">ty_cts</span></a></span><span> </span><span class="annot"><span class="annottext">PmCts -&gt; PmCts -&gt; PmCts
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">[PmCt] -&gt; PmCts
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146598"><span class="hs-identifier hs-var">tm_cts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1152"></span><span>    </span><span class="annot"><span class="annottext">Maybe (PmAltCon, [Id], [Id])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1153"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146596"><span class="annot"><span class="annottext">pos' :: [(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146596"><span class="hs-identifier hs-var hs-var">pos'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146615"><span class="hs-identifier hs-var">alt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146614"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146613"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id])
-&gt; [(PmAltCon, [Id], [Id])] -&gt; [(PmAltCon, [Id], [Id])]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146611"><span class="hs-identifier hs-var">pos</span></a></span><span>
</span><span id="line-1154"></span><span>      </span><span class="annot"><span class="annottext">Delta -&gt; MaybeT DsM Delta
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146619"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; CoreMap Id -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-var">TmSt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo -&gt; Id -&gt; VarInfo -&gt; SharedDIdEnv VarInfo
forall a. SharedDIdEnv a -&gt; Id -&gt; a -&gt; SharedDIdEnv a
</span><a href="GHC.HsToCore.PmCheck.Types.html#setEntrySDIE"><span class="hs-identifier hs-var">setEntrySDIE</span></a></span><span> </span><span class="annot"><span class="annottext">SharedDIdEnv VarInfo
</span><a href="#local-6989586621681146618"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146616"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
-&gt; [(PmAltCon, [Id], [Id])]
-&gt; PmAltConSet
-&gt; PossibleMatches
-&gt; VarInfo
</span><a href="GHC.HsToCore.PmCheck.Types.html#VI"><span class="hs-identifier hs-var">VI</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146612"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146596"><span class="hs-identifier hs-var">pos'</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146610"><span class="hs-identifier hs-var">neg</span></a></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="#local-6989586621681146609"><span class="hs-identifier hs-var">cache</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146617"><span class="hs-identifier hs-var">reps</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-1155"></span><span>
</span><span id="line-1156"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#equateTys"><span class="hs-identifier hs-type">equateTys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1157"></span><span id="equateTys"><span class="annot"><span class="annottext">equateTys :: [Type] -&gt; [Type] -&gt; [PmCt]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#equateTys"><span class="hs-identifier hs-var hs-var">equateTys</span></a></span></span><span> </span><span id="local-6989586621681146595"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146595"><span class="hs-identifier hs-var">ts</span></a></span></span><span> </span><span id="local-6989586621681146594"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146594"><span class="hs-identifier hs-var">us</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1158"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTyCt"><span class="hs-identifier hs-var">PmTyCt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Type
</span><a href="GHC.Core.Coercion.html#mkPrimEqPred"><span class="hs-identifier hs-var">mkPrimEqPred</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146592"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146591"><span class="hs-identifier hs-var">u</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1159"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146592"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146592"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146591"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146591"><span class="hs-identifier hs-var">u</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; [Type] -&gt; [Type] -&gt; [(Type, Type)]
forall a b. String -&gt; [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="GHC.Utils.Misc.html#zipEqual"><span class="hs-identifier hs-var">zipEqual</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;equateTys&quot;</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146595"><span class="hs-identifier hs-var">ts</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146594"><span class="hs-identifier hs-var">us</span></a></span><span>
</span><span id="line-1160"></span><span>  </span><span class="hs-comment">-- The following line filters out trivial Refl constraints, so that we don't</span><span>
</span><span id="line-1161"></span><span>  </span><span class="hs-comment">-- need to initialise the type oracle that often</span><span>
</span><span id="line-1162"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-identifier hs-var">eqType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146592"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146591"><span class="hs-identifier hs-var">u</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1163"></span><span>  </span><span class="hs-special">]</span><span>
</span><span id="line-1164"></span><span>
</span><span id="line-1165"></span><span class="hs-comment">----------------------------------------</span><span>
</span><span id="line-1166"></span><span class="hs-comment">-- * Enumerating inhabitation candidates</span><span>
</span><span id="line-1167"></span><span>
</span><span id="line-1168"></span><span class="hs-comment">-- | Information about a conlike that is relevant to coverage checking.</span><span>
</span><span id="line-1169"></span><span class="hs-comment">-- It is called an \&quot;inhabitation candidate\&quot; since it is a value which may</span><span>
</span><span id="line-1170"></span><span class="hs-comment">-- possibly inhabit some type, but only if its term constraints ('ic_tm_cs')</span><span>
</span><span id="line-1171"></span><span class="hs-comment">-- and type constraints ('ic_ty_cs') are permitting, and if all of its strict</span><span>
</span><span id="line-1172"></span><span class="hs-comment">-- argument types ('ic_strict_arg_tys') are inhabitable.</span><span>
</span><span id="line-1173"></span><span class="hs-comment">-- See @Note [Strict argument type constraints]@.</span><span>
</span><span id="line-1174"></span><span class="hs-keyword">data</span><span> </span><span id="InhabitationCandidate"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-var">InhabitationCandidate</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1175"></span><span>  </span><span id="InhabitationCandidate"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-var">InhabitationCandidate</span></a></span></span><span>
</span><span id="line-1176"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="ic_cs"><span class="annot"><span class="annottext">InhabitationCandidate -&gt; PmCts
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_cs"><span class="hs-identifier hs-var hs-var">ic_cs</span></a></span></span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCts"><span class="hs-identifier hs-type">PmCts</span></a></span><span>
</span><span id="line-1177"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="ic_strict_arg_tys"><span class="annot"><span class="annottext">InhabitationCandidate -&gt; [Type]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_strict_arg_tys"><span class="hs-identifier hs-var hs-var">ic_strict_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1178"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-1179"></span><span>
</span><span id="line-1180"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681146584"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1181"></span><span>  </span><span id="local-6989586621681146580"><span class="annot"><span class="annottext">ppr :: InhabitationCandidate -&gt; SDoc
</span><a href="#local-6989586621681146580"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span><span> </span><span id="local-6989586621681146579"><span class="annot"><span class="annottext">PmCts
</span><a href="#local-6989586621681146579"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span id="local-6989586621681146578"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146578"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1182"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;InhabitationCandidate&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-1183"></span><span>      </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ic_cs             =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PmCts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PmCts
</span><a href="#local-6989586621681146579"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-1184"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ic_strict_arg_tys =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146578"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1185"></span><span>
</span><span id="line-1186"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#mkInhabitationCandidate"><span class="hs-identifier hs-type">mkInhabitationCandidate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span><span>
</span><span id="line-1187"></span><span class="hs-comment">-- Precondition: idType x is a TyConApp, so that tyConAppArgs in here is safe.</span><span>
</span><span id="line-1188"></span><span id="mkInhabitationCandidate"><span class="annot"><span class="annottext">mkInhabitationCandidate :: Id -&gt; DataCon -&gt; DsM InhabitationCandidate
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkInhabitationCandidate"><span class="hs-identifier hs-var hs-var">mkInhabitationCandidate</span></a></span></span><span> </span><span id="local-6989586621681146576"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146576"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146575"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146575"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1189"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146574"><span class="annot"><span class="annottext">cl :: ConLike
</span><a href="#local-6989586621681146574"><span class="hs-identifier hs-var hs-var">cl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; ConLike
</span><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-var">RealDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146575"><span class="hs-identifier hs-var">dc</span></a></span><span>
</span><span id="line-1190"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146573"><span class="annot"><span class="annottext">tc_args :: [Type]
</span><a href="#local-6989586621681146573"><span class="hs-identifier hs-var hs-var">tc_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type]
</span><a href="GHC.Core.Type.html#tyConAppArgs"><span class="hs-identifier hs-var">tyConAppArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146576"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1191"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621681146571"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146571"><span class="hs-identifier hs-var">ty_vars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146570"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146570"><span class="hs-identifier hs-var">arg_vars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146569"><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146569"><span class="hs-identifier hs-var">ty_cs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146568"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146568"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; ConLike -&gt; DsM ([Id], [Id], Bag Type, [Type])
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkOneConFull"><span class="hs-identifier hs-var">mkOneConFull</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146573"><span class="hs-identifier hs-var">tc_args</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146574"><span class="hs-identifier hs-var">cl</span></a></span><span>
</span><span id="line-1192"></span><span>  </span><span class="annot"><span class="annottext">InhabitationCandidate -&gt; DsM InhabitationCandidate
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">InhabitationCandidate :: PmCts -&gt; [Type] -&gt; InhabitationCandidate
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span><span>
</span><span id="line-1193"></span><span>        </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_cs :: PmCts
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_cs"><span class="hs-identifier hs-var">ic_cs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#PmTyCt"><span class="hs-identifier hs-var">PmTyCt</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; PmCt) -&gt; Bag Type -&gt; PmCts
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146569"><span class="hs-identifier hs-var">ty_cs</span></a></span><span> </span><span class="annot"><span class="annottext">PmCts -&gt; PmCt -&gt; PmCts
forall a. Bag a -&gt; a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#snocBag"><span class="hs-operator hs-var">`snocBag`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#PmConCt"><span class="hs-identifier hs-var">PmConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146576"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; PmAltCon
</span><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-var">PmAltConLike</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146574"><span class="hs-identifier hs-var">cl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146571"><span class="hs-identifier hs-var">ty_vars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146570"><span class="hs-identifier hs-var">arg_vars</span></a></span><span>
</span><span id="line-1194"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_strict_arg_tys :: [Type]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_strict_arg_tys"><span class="hs-identifier hs-var">ic_strict_arg_tys</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146568"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span>
</span><span id="line-1195"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-1196"></span><span>
</span><span id="line-1197"></span><span class="hs-comment">-- | Generate all 'InhabitationCandidate's for a given type. The result is</span><span>
</span><span id="line-1198"></span><span class="hs-comment">-- either @'Left' ty@, if the type cannot be reduced to a closed algebraic type</span><span>
</span><span id="line-1199"></span><span class="hs-comment">-- (or if it's one trivially inhabited, like 'Int'), or @'Right' candidates@,</span><span>
</span><span id="line-1200"></span><span class="hs-comment">-- if it can. In this case, the candidates are the signature of the tycon, each</span><span>
</span><span id="line-1201"></span><span class="hs-comment">-- one accompanied by the term- and type- constraints it gives rise to.</span><span>
</span><span id="line-1202"></span><span class="hs-comment">-- See also Note [Checking EmptyCase Expressions]</span><span>
</span><span id="line-1203"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#inhabitationCandidates"><span class="hs-identifier hs-type">inhabitationCandidates</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-1204"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1205"></span><span id="inhabitationCandidates"><span class="annot"><span class="annottext">inhabitationCandidates :: Delta
-&gt; Type -&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#inhabitationCandidates"><span class="hs-identifier hs-var hs-var">inhabitationCandidates</span></a></span></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_ty_st :: Delta -&gt; TyState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_ty_st"><span class="hs-identifier hs-var">delta_ty_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146565"><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146565"><span class="hs-identifier hs-var">ty_st</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146564"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146564"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1206"></span><span>  </span><span class="annot"><span class="annottext">TyState -&gt; Type -&gt; DsM TopNormaliseTypeResult
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmTopNormaliseType"><span class="hs-identifier hs-var">pmTopNormaliseType</span></a></span><span> </span><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146565"><span class="hs-identifier hs-var">ty_st</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146564"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">DsM TopNormaliseTypeResult
-&gt; (TopNormaliseTypeResult
    -&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate])))
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-glyph">case</span><span>
</span><span id="line-1207"></span><span>    </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NoChange"><span class="hs-identifier hs-type">NoChange</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type
-&gt; Type
-&gt; [(Type, DataCon, Type)]
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
</span><a href="#local-6989586621681146563"><span class="hs-identifier hs-var">alts_to_check</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146564"><span class="hs-identifier hs-var">ty</span></a></span><span>     </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146564"><span class="hs-identifier hs-var">ty</span></a></span><span>      </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1208"></span><span>    </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#NormalisedByConstraints"><span class="hs-identifier hs-type">NormalisedByConstraints</span></a></span><span> </span><span id="local-6989586621681146562"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146562"><span class="hs-identifier hs-var">ty'</span></a></span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type
-&gt; Type
-&gt; [(Type, DataCon, Type)]
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
</span><a href="#local-6989586621681146563"><span class="hs-identifier hs-var">alts_to_check</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146562"><span class="hs-identifier hs-var">ty'</span></a></span><span>    </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146562"><span class="hs-identifier hs-var">ty'</span></a></span><span>     </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1209"></span><span>    </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#HadRedexes"><span class="hs-identifier hs-type">HadRedexes</span></a></span><span> </span><span id="local-6989586621681146561"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146561"><span class="hs-identifier hs-var">src_ty</span></a></span></span><span> </span><span id="local-6989586621681146560"><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146560"><span class="hs-identifier hs-var">dcs</span></a></span></span><span> </span><span id="local-6989586621681146559"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146559"><span class="hs-identifier hs-var">core_ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type
-&gt; Type
-&gt; [(Type, DataCon, Type)]
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
</span><a href="#local-6989586621681146563"><span class="hs-identifier hs-var">alts_to_check</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146561"><span class="hs-identifier hs-var">src_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146559"><span class="hs-identifier hs-var">core_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146560"><span class="hs-identifier hs-var">dcs</span></a></span><span>
</span><span id="line-1210"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1211"></span><span>    </span><span class="annot"><a href="#local-6989586621681146558"><span class="hs-identifier hs-type">build_newtype</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1212"></span><span>    </span><span id="local-6989586621681146558"><span class="annot"><span class="annottext">build_newtype :: (Type, DataCon, Type) -&gt; Id -&gt; DsM (Id, PmCt)
</span><a href="#local-6989586621681146558"><span class="hs-identifier hs-var hs-var">build_newtype</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146557"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146557"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146556"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146556"><span class="hs-identifier hs-var">dc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146555"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146555"><span class="hs-identifier hs-var">_arg_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681146554"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146554"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1213"></span><span>      </span><span class="hs-comment">-- ty is the type of @dc x@. It's a @dataConTyCon dc@ application.</span><span>
</span><span id="line-1214"></span><span>      </span><span id="local-6989586621681146553"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146553"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-var">mkPmId</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146557"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1215"></span><span>      </span><span class="hs-comment">-- Newtypes don't have existentials (yet?!), so passing an empty list as</span><span>
</span><span id="line-1216"></span><span>      </span><span class="hs-comment">-- ex_tvs.</span><span>
</span><span id="line-1217"></span><span>      </span><span class="annot"><span class="annottext">(Id, PmCt) -&gt; DsM (Id, PmCt)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146553"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; PmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#PmConCt"><span class="hs-identifier hs-var">PmConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146553"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; PmAltCon
</span><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-var">PmAltConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; ConLike
</span><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-var">RealDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146556"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146554"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1218"></span><span>
</span><span id="line-1219"></span><span>    </span><span class="annot"><a href="#local-6989586621681146552"><span class="hs-identifier hs-type">build_newtypes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#PmCt"><span class="hs-identifier hs-type">PmCt</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1220"></span><span>    </span><span id="local-6989586621681146552"><span class="annot"><span class="annottext">build_newtypes :: Id -&gt; [(Type, DataCon, Type)] -&gt; DsM (Id, [PmCt])
</span><a href="#local-6989586621681146552"><span class="hs-identifier hs-var hs-var">build_newtypes</span></a></span></span><span> </span><span id="local-6989586621681146551"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146551"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Type, DataCon, Type) -&gt; (Id, [PmCt]) -&gt; DsM (Id, [PmCt]))
-&gt; (Id, [PmCt]) -&gt; [(Type, DataCon, Type)] -&gt; DsM (Id, [PmCt])
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; b -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldrM"><span class="hs-identifier hs-var">foldrM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681146549"><span class="annot"><span class="annottext">(Type, DataCon, Type)
</span><a href="#local-6989586621681146549"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146548"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146548"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146547"><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146547"><span class="hs-identifier hs-var">cts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Type, DataCon, Type) -&gt; Id -&gt; [PmCt] -&gt; DsM (Id, [PmCt])
</span><a href="#local-6989586621681146546"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">(Type, DataCon, Type)
</span><a href="#local-6989586621681146549"><span class="hs-identifier hs-var">dc</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146548"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146547"><span class="hs-identifier hs-var">cts</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146551"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1221"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1222"></span><span>        </span><span id="local-6989586621681146546"><span class="annot"><span class="annottext">go :: (Type, DataCon, Type) -&gt; Id -&gt; [PmCt] -&gt; DsM (Id, [PmCt])
</span><a href="#local-6989586621681146546"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681146542"><span class="annot"><span class="annottext">(Type, DataCon, Type)
</span><a href="#local-6989586621681146542"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span id="local-6989586621681146541"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146541"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146540"><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146540"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(PmCt -&gt; [PmCt]) -&gt; (Id, PmCt) -&gt; (Id, [PmCt])
forall (p :: * -&gt; * -&gt; *) b c a.
Bifunctor p =&gt;
(b -&gt; c) -&gt; p a b -&gt; p a c
</span><a href="../../base/src/Data.Bifunctor.html#second"><span class="hs-identifier hs-var">second</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmCt -&gt; [PmCt] -&gt; [PmCt]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146540"><span class="hs-identifier hs-var">cts</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Id, PmCt) -&gt; (Id, [PmCt])) -&gt; DsM (Id, PmCt) -&gt; DsM (Id, [PmCt])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(Type, DataCon, Type) -&gt; Id -&gt; DsM (Id, PmCt)
</span><a href="#local-6989586621681146558"><span class="hs-identifier hs-var">build_newtype</span></a></span><span> </span><span class="annot"><span class="annottext">(Type, DataCon, Type)
</span><a href="#local-6989586621681146542"><span class="hs-identifier hs-var">dc</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146541"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-1223"></span><span>
</span><span id="line-1224"></span><span>    </span><span class="hs-comment">-- Inhabitation candidates, using the result of pmTopNormaliseType</span><span>
</span><span id="line-1225"></span><span>    </span><span class="annot"><a href="#local-6989586621681146563"><span class="hs-identifier hs-type">alts_to_check</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1226"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1227"></span><span>    </span><span id="local-6989586621681146563"><span class="annot"><span class="annottext">alts_to_check :: Type
-&gt; Type
-&gt; [(Type, DataCon, Type)]
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
</span><a href="#local-6989586621681146563"><span class="hs-identifier hs-var hs-var">alts_to_check</span></a></span></span><span> </span><span id="local-6989586621681146539"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146539"><span class="hs-identifier hs-var">src_ty</span></a></span></span><span> </span><span id="local-6989586621681146538"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146538"><span class="hs-identifier hs-var">core_ty</span></a></span></span><span> </span><span id="local-6989586621681146537"><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146537"><span class="hs-identifier hs-var">dcs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146538"><span class="hs-identifier hs-var">core_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1228"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146536"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146536"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-1229"></span><span>        </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#isTyConTriviallyInhabited"><span class="hs-identifier hs-var">isTyConTriviallyInhabited</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146536"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-1230"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146537"><span class="hs-identifier hs-var">dcs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1231"></span><span>             </span><span class="hs-special">[</span><span class="hs-special">]</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either Type (TyCon, Id, [InhabitationCandidate])
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Either Type (TyCon, Id, [InhabitationCandidate])
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146539"><span class="hs-identifier hs-var">src_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1232"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type, DataCon, Type)
</span><span class="hs-identifier">_</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681146534"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146534"><span class="hs-identifier hs-var">inner</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-var">mkPmId</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146538"><span class="hs-identifier hs-var">core_ty</span></a></span><span>
</span><span id="line-1233"></span><span>                         </span><span class="hs-special">(</span><span id="local-6989586621681146533"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146533"><span class="hs-identifier hs-var">outer</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146532"><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146532"><span class="hs-identifier hs-var">new_tm_cts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [(Type, DataCon, Type)] -&gt; DsM (Id, [PmCt])
</span><a href="#local-6989586621681146552"><span class="hs-identifier hs-var">build_newtypes</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146534"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146537"><span class="hs-identifier hs-var">dcs</span></a></span><span>
</span><span id="line-1234"></span><span>                         </span><span class="annot"><span class="annottext">Either Type (TyCon, Id, [InhabitationCandidate])
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either Type (TyCon, Id, [InhabitationCandidate])
 -&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate])))
-&gt; Either Type (TyCon, Id, [InhabitationCandidate])
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCon, Id, [InhabitationCandidate])
-&gt; Either Type (TyCon, Id, [InhabitationCandidate])
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146536"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146533"><span class="hs-identifier hs-var">outer</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">InhabitationCandidate :: PmCts -&gt; [Type] -&gt; InhabitationCandidate
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span><span>
</span><span id="line-1235"></span><span>                           </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_cs :: PmCts
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_cs"><span class="hs-identifier hs-var">ic_cs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[PmCt] -&gt; PmCts
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146532"><span class="hs-identifier hs-var">new_tm_cts</span></a></span><span>
</span><span id="line-1236"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_strict_arg_tys :: [Type]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_strict_arg_tys"><span class="hs-identifier hs-var">ic_strict_arg_tys</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1237"></span><span>
</span><span id="line-1238"></span><span>        </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmIsClosedType"><span class="hs-identifier hs-var">pmIsClosedType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146538"><span class="hs-identifier hs-var">core_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isAbstractTyCon"><span class="hs-identifier hs-var">isAbstractTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146536"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1239"></span><span>           </span><span class="hs-comment">-- Don't consider abstract tycons since we don't know what their</span><span>
</span><span id="line-1240"></span><span>           </span><span class="hs-comment">-- constructors are, which makes the results of coverage checking</span><span>
</span><span id="line-1241"></span><span>           </span><span class="hs-comment">-- them extremely misleading.</span><span>
</span><span id="line-1242"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1243"></span><span>             </span><span id="local-6989586621681146530"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146530"><span class="hs-identifier hs-var">inner</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-var">mkPmId</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146538"><span class="hs-identifier hs-var">core_ty</span></a></span><span> </span><span class="hs-comment">-- it would be wrong to unify inner</span><span>
</span><span id="line-1244"></span><span>             </span><span id="local-6989586621681146529"><span class="annot"><span class="annottext">[InhabitationCandidate]
</span><a href="#local-6989586621681146529"><span class="hs-identifier hs-var">alts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(DataCon -&gt; DsM InhabitationCandidate)
-&gt; [DataCon]
-&gt; IOEnv (Env DsGblEnv DsLclEnv) [InhabitationCandidate]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; DataCon -&gt; DsM InhabitationCandidate
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkInhabitationCandidate"><span class="hs-identifier hs-var">mkInhabitationCandidate</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146530"><span class="hs-identifier hs-var">inner</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146536"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1245"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621681146527"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146527"><span class="hs-identifier hs-var">outer</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146526"><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146526"><span class="hs-identifier hs-var">new_cts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [(Type, DataCon, Type)] -&gt; DsM (Id, [PmCt])
</span><a href="#local-6989586621681146552"><span class="hs-identifier hs-var">build_newtypes</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146530"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146537"><span class="hs-identifier hs-var">dcs</span></a></span><span>
</span><span id="line-1246"></span><span>             </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146525"><span class="annot"><span class="annottext">wrap_dcs :: InhabitationCandidate -&gt; InhabitationCandidate
</span><a href="#local-6989586621681146525"><span class="hs-identifier hs-var hs-var">wrap_dcs</span></a></span></span><span> </span><span id="local-6989586621681146524"><span class="annot"><span class="annottext">InhabitationCandidate
</span><a href="#local-6989586621681146524"><span class="hs-identifier hs-var">alt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InhabitationCandidate
</span><a href="#local-6989586621681146524"><span class="hs-identifier hs-var">alt</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_cs :: PmCts
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_cs"><span class="hs-identifier hs-var">ic_cs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[PmCt] -&gt; PmCts
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146526"><span class="hs-identifier hs-var">new_cts</span></a></span><span> </span><span class="annot"><span class="annottext">PmCts -&gt; PmCts -&gt; PmCts
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">InhabitationCandidate -&gt; PmCts
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_cs"><span class="hs-identifier hs-var hs-var">ic_cs</span></a></span><span> </span><span class="annot"><span class="annottext">InhabitationCandidate
</span><a href="#local-6989586621681146524"><span class="hs-identifier hs-var">alt</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-1247"></span><span>             </span><span class="annot"><span class="annottext">Either Type (TyCon, Id, [InhabitationCandidate])
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either Type (TyCon, Id, [InhabitationCandidate])
 -&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate])))
-&gt; Either Type (TyCon, Id, [InhabitationCandidate])
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCon, Id, [InhabitationCandidate])
-&gt; Either Type (TyCon, Id, [InhabitationCandidate])
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146536"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146527"><span class="hs-identifier hs-var">outer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(InhabitationCandidate -&gt; InhabitationCandidate)
-&gt; [InhabitationCandidate] -&gt; [InhabitationCandidate]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">InhabitationCandidate -&gt; InhabitationCandidate
</span><a href="#local-6989586621681146525"><span class="hs-identifier hs-var">wrap_dcs</span></a></span><span> </span><span class="annot"><span class="annottext">[InhabitationCandidate]
</span><a href="#local-6989586621681146529"><span class="hs-identifier hs-var">alts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1248"></span><span>      </span><span class="hs-comment">-- For other types conservatively assume that they are inhabited.</span><span>
</span><span id="line-1249"></span><span>      </span><span id="local-6989586621681146523"><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621681146523"><span class="hs-identifier hs-var">_other</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either Type (TyCon, Id, [InhabitationCandidate])
-&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Either Type (TyCon, Id, [InhabitationCandidate])
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146539"><span class="hs-identifier hs-var">src_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1250"></span><span>
</span><span id="line-1251"></span><span class="hs-comment">-- | All these types are trivially inhabited</span><span>
</span><span id="line-1252"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#triviallyInhabitedTyCons"><span class="hs-identifier hs-type">triviallyInhabitedTyCons</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#UniqSet"><span class="hs-identifier hs-type">UniqSet</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-1253"></span><span id="triviallyInhabitedTyCons"><span class="annot"><span class="annottext">triviallyInhabitedTyCons :: UniqSet TyCon
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#triviallyInhabitedTyCons"><span class="hs-identifier hs-var hs-var">triviallyInhabitedTyCons</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCon] -&gt; UniqSet TyCon
forall a. Uniquable a =&gt; [a] -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#mkUniqSet"><span class="hs-identifier hs-var">mkUniqSet</span></a></span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-1254"></span><span>    </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.html#charTyCon"><span class="hs-identifier hs-var">charTyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.html#doubleTyCon"><span class="hs-identifier hs-var">doubleTyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.html#floatTyCon"><span class="hs-identifier hs-var">floatTyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.html#intTyCon"><span class="hs-identifier hs-var">intTyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.html#wordTyCon"><span class="hs-identifier hs-var">wordTyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.html#word8TyCon"><span class="hs-identifier hs-var">word8TyCon</span></a></span><span>
</span><span id="line-1255"></span><span>  </span><span class="hs-special">]</span><span>
</span><span id="line-1256"></span><span>
</span><span id="line-1257"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#isTyConTriviallyInhabited"><span class="hs-identifier hs-type">isTyConTriviallyInhabited</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1258"></span><span id="isTyConTriviallyInhabited"><span class="annot"><span class="annottext">isTyConTriviallyInhabited :: TyCon -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#isTyConTriviallyInhabited"><span class="hs-identifier hs-var hs-var">isTyConTriviallyInhabited</span></a></span></span><span> </span><span id="local-6989586621681146514"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146514"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; UniqSet TyCon -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; UniqSet a -&gt; Bool
</span><a href="GHC.Types.Unique.Set.html#elementOfUniqSet"><span class="hs-identifier hs-var">elementOfUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146514"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet TyCon
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#triviallyInhabitedTyCons"><span class="hs-identifier hs-var">triviallyInhabitedTyCons</span></a></span><span>
</span><span id="line-1259"></span><span>
</span><span id="line-1260"></span><span class="hs-comment">----------------------------</span><span>
</span><span id="line-1261"></span><span class="hs-comment">-- * Detecting vacuous types</span><span>
</span><span id="line-1262"></span><span>
</span><span id="line-1263"></span><span class="hs-comment">{- Note [Checking EmptyCase Expressions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Empty case expressions are strict on the scrutinee. That is, `case x of {}`
will force argument `x`. Hence, `checkMatches` is not sufficient for checking
empty cases, because it assumes that the match is not strict (which is true
for all other cases, apart from EmptyCase). This gave rise to #10746. Instead,
we do the following:

1. We normalise the outermost type family redex, data family redex or newtype,
   using pmTopNormaliseType (in &quot;GHC.Core.FamInstEnv&quot;). This computes 3
   things:
   (a) A normalised type src_ty, which is equal to the type of the scrutinee in
       source Haskell (does not normalise newtypes or data families)
   (b) The actual normalised type core_ty, which coincides with the result
       topNormaliseType_maybe. This type is not necessarily equal to the input
       type in source Haskell. And this is precicely the reason we compute (a)
       and (c): the reasoning happens with the underlying types, but both the
       patterns and types we print should respect newtypes and also show the
       family type constructors and not the representation constructors.

   (c) A list of all newtype data constructors dcs, each one corresponding to a
       newtype rewrite performed in (b).

   For an example see also Note [Type normalisation]
   in &quot;GHC.Core.FamInstEnv&quot;.

2. Function Check.checkEmptyCase' performs the check:
   - If core_ty is not an algebraic type, then we cannot check for
     inhabitation, so we emit (_ :: src_ty) as missing, conservatively assuming
     that the type is inhabited.
   - If core_ty is an algebraic type, then we unfold the scrutinee to all
     possible constructor patterns, using inhabitationCandidates, and then
     check each one for constraint satisfiability, same as we do for normal
     pattern match checking.
-}</span><span>
</span><span id="line-1298"></span><span>
</span><span id="line-1299"></span><span class="hs-comment">-- | A 'SatisfiabilityCheck' based on &quot;NonVoid ty&quot; constraints, e.g. Will</span><span>
</span><span id="line-1300"></span><span class="hs-comment">-- check if the @strict_arg_tys@ are actually all inhabited.</span><span>
</span><span id="line-1301"></span><span class="hs-comment">-- Returns the old 'Delta' if all the types are non-void according to 'Delta'.</span><span>
</span><span id="line-1302"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#tysAreNonVoid"><span class="hs-identifier hs-type">tysAreNonVoid</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#RecTcChecker"><span class="hs-identifier hs-type">RecTcChecker</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#SatisfiabilityCheck"><span class="hs-identifier hs-type">SatisfiabilityCheck</span></a></span><span>
</span><span id="line-1303"></span><span id="tysAreNonVoid"><span class="annot"><span class="annottext">tysAreNonVoid :: RecTcChecker -&gt; [Type] -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tysAreNonVoid"><span class="hs-identifier hs-var hs-var">tysAreNonVoid</span></a></span></span><span> </span><span id="local-6989586621681146512"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146512"><span class="hs-identifier hs-var">rec_env</span></a></span></span><span> </span><span id="local-6989586621681146511"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146511"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#SC"><span class="hs-identifier hs-var">SC</span></a></span><span> </span><span class="annot"><span class="annottext">((Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck)
-&gt; (Delta -&gt; DsM (Maybe Delta)) -&gt; SatisfiabilityCheck
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681146510"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146510"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1304"></span><span>  </span><span id="local-6989586621681146509"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681146509"><span class="hs-identifier hs-var">all_non_void</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RecTcChecker
-&gt; Delta -&gt; [Type] -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#checkAllNonVoid"><span class="hs-identifier hs-var">checkAllNonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146512"><span class="hs-identifier hs-var">rec_env</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146510"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146511"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span>
</span><span id="line-1305"></span><span>  </span><span class="hs-comment">-- Check if each strict argument type is inhabitable</span><span>
</span><span id="line-1306"></span><span>  </span><span class="annot"><span class="annottext">Maybe Delta -&gt; DsM (Maybe Delta)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Delta -&gt; DsM (Maybe Delta))
-&gt; Maybe Delta -&gt; DsM (Maybe Delta)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681146509"><span class="hs-identifier hs-var">all_non_void</span></a></span><span>
</span><span id="line-1307"></span><span>            </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Maybe Delta
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146510"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-1308"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe Delta
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1309"></span><span>
</span><span id="line-1310"></span><span class="hs-comment">-- | Implements two performance optimizations, as described in</span><span>
</span><span id="line-1311"></span><span class="hs-comment">-- @Note [Strict argument type constraints]@.</span><span>
</span><span id="line-1312"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#checkAllNonVoid"><span class="hs-identifier hs-type">checkAllNonVoid</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#RecTcChecker"><span class="hs-identifier hs-type">RecTcChecker</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1313"></span><span id="checkAllNonVoid"><span class="annot"><span class="annottext">checkAllNonVoid :: RecTcChecker
-&gt; Delta -&gt; [Type] -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#checkAllNonVoid"><span class="hs-identifier hs-var hs-var">checkAllNonVoid</span></a></span></span><span> </span><span id="local-6989586621681146507"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146507"><span class="hs-identifier hs-var">rec_ts</span></a></span></span><span> </span><span id="local-6989586621681146506"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146506"><span class="hs-identifier hs-var">amb_cs</span></a></span></span><span> </span><span id="local-6989586621681146505"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146505"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1314"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146504"><span class="annot"><span class="annottext">definitely_inhabited :: Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="#local-6989586621681146504"><span class="hs-identifier hs-var hs-var">definitely_inhabited</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyState -&gt; Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#definitelyInhabitedType"><span class="hs-identifier hs-var">definitelyInhabitedType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; TyState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_ty_st"><span class="hs-identifier hs-var hs-var">delta_ty_st</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146506"><span class="hs-identifier hs-var">amb_cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1315"></span><span>  </span><span id="local-6989586621681146502"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146502"><span class="hs-identifier hs-var">tys_to_check</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool)
-&gt; [Type] -&gt; IOEnv (Env DsGblEnv DsLclEnv) [Type]
forall (m :: * -&gt; *) a.
Applicative m =&gt;
(a -&gt; m Bool) -&gt; [a] -&gt; m [a]
</span><a href="GHC.Utils.Monad.html#filterOutM"><span class="hs-identifier hs-var">filterOutM</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="#local-6989586621681146504"><span class="hs-identifier hs-var">definitely_inhabited</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146505"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span>
</span><span id="line-1316"></span><span>  </span><span class="hs-comment">-- See Note [Fuel for the inhabitation test]</span><span>
</span><span id="line-1317"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146498"><span class="annot"><span class="annottext">rec_max_bound :: Int
</span><a href="#local-6989586621681146498"><span class="hs-identifier hs-var hs-var">rec_max_bound</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146502"><span class="hs-identifier hs-var">tys_to_check</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Int -&gt; Bool
forall a. [a] -&gt; Int -&gt; Bool
</span><a href="GHC.Utils.Misc.html#lengthExceeds"><span class="hs-operator hs-var">`lengthExceeds`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1318"></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1319"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1320"></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span>
</span><span id="line-1321"></span><span>      </span><span id="local-6989586621681146496"><span class="annot"><span class="annottext">rec_ts' :: RecTcChecker
</span><a href="#local-6989586621681146496"><span class="hs-identifier hs-var hs-var">rec_ts'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; RecTcChecker -&gt; RecTcChecker
</span><a href="GHC.Core.TyCon.html#setRecTcMaxBound"><span class="hs-identifier hs-var">setRecTcMaxBound</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146498"><span class="hs-identifier hs-var">rec_max_bound</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146507"><span class="hs-identifier hs-var">rec_ts</span></a></span><span>
</span><span id="line-1322"></span><span>  </span><span class="annot"><span class="annottext">(Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool)
-&gt; [Type] -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall (m :: * -&gt; *) a. Monad m =&gt; (a -&gt; m Bool) -&gt; [a] -&gt; m Bool
</span><a href="GHC.Utils.Monad.html#allM"><span class="hs-identifier hs-var">allM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RecTcChecker -&gt; Delta -&gt; Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#nonVoid"><span class="hs-identifier hs-var">nonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146496"><span class="hs-identifier hs-var">rec_ts'</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146506"><span class="hs-identifier hs-var">amb_cs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146502"><span class="hs-identifier hs-var">tys_to_check</span></a></span><span>
</span><span id="line-1323"></span><span>
</span><span id="line-1324"></span><span class="hs-comment">-- | Checks if a strict argument type of a conlike is inhabitable by a</span><span>
</span><span id="line-1325"></span><span class="hs-comment">-- terminating value (i.e, an 'InhabitationCandidate').</span><span>
</span><span id="line-1326"></span><span class="hs-comment">-- See @Note [Strict argument type constraints]@.</span><span>
</span><span id="line-1327"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#nonVoid"><span class="hs-identifier hs-type">nonVoid</span></a></span><span>
</span><span id="line-1328"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#RecTcChecker"><span class="hs-identifier hs-type">RecTcChecker</span></a></span><span> </span><span class="hs-comment">-- ^ The per-'TyCon' recursion depth limit.</span><span>
</span><span id="line-1329"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>        </span><span class="hs-comment">-- ^ The ambient term/type constraints (known to be</span><span>
</span><span id="line-1330"></span><span>                  </span><span class="hs-comment">--   satisfiable).</span><span>
</span><span id="line-1331"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>         </span><span class="hs-comment">-- ^ The strict argument type.</span><span>
</span><span id="line-1332"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>     </span><span class="hs-comment">-- ^ 'True' if the strict argument type might be inhabited by</span><span>
</span><span id="line-1333"></span><span>                  </span><span class="hs-comment">--   a terminating value (i.e., an 'InhabitationCandidate').</span><span>
</span><span id="line-1334"></span><span>                  </span><span class="hs-comment">--   'False' if it is definitely uninhabitable by anything</span><span>
</span><span id="line-1335"></span><span>                  </span><span class="hs-comment">--   (except bottom).</span><span>
</span><span id="line-1336"></span><span id="nonVoid"><span class="annot"><span class="annottext">nonVoid :: RecTcChecker -&gt; Delta -&gt; Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#nonVoid"><span class="hs-identifier hs-var hs-var">nonVoid</span></a></span></span><span> </span><span id="local-6989586621681146492"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146492"><span class="hs-identifier hs-var">rec_ts</span></a></span></span><span> </span><span id="local-6989586621681146491"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146491"><span class="hs-identifier hs-var">amb_cs</span></a></span></span><span> </span><span id="local-6989586621681146490"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146490"><span class="hs-identifier hs-var">strict_arg_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1337"></span><span>  </span><span id="local-6989586621681146489"><span class="annot"><span class="annottext">Either Type (TyCon, Id, [InhabitationCandidate])
</span><a href="#local-6989586621681146489"><span class="hs-identifier hs-var">mb_cands</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Delta
-&gt; Type -&gt; DsM (Either Type (TyCon, Id, [InhabitationCandidate]))
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#inhabitationCandidates"><span class="hs-identifier hs-var">inhabitationCandidates</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146491"><span class="hs-identifier hs-var">amb_cs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146490"><span class="hs-identifier hs-var">strict_arg_ty</span></a></span><span>
</span><span id="line-1338"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either Type (TyCon, Id, [InhabitationCandidate])
</span><a href="#local-6989586621681146489"><span class="hs-identifier hs-var">mb_cands</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1339"></span><span>    </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146488"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146488"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146487"><span class="annot"><span class="annottext">[InhabitationCandidate]
</span><a href="#local-6989586621681146487"><span class="hs-identifier hs-var">cands</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1340"></span><span>      </span><span class="hs-comment">-- See Note [Fuel for the inhabitation test]</span><span>
</span><span id="line-1341"></span><span>      </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146486"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146486"><span class="hs-identifier hs-var">rec_ts'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; TyCon -&gt; Maybe RecTcChecker
</span><a href="GHC.Core.TyCon.html#checkRecTc"><span class="hs-identifier hs-var">checkRecTc</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146492"><span class="hs-identifier hs-var">rec_ts</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681146488"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-1342"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(InhabitationCandidate -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool)
-&gt; [InhabitationCandidate] -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall (m :: * -&gt; *) a. Monad m =&gt; (a -&gt; m Bool) -&gt; [a] -&gt; m Bool
</span><a href="GHC.Utils.Monad.html#anyM"><span class="hs-identifier hs-var">anyM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RecTcChecker
-&gt; Delta
-&gt; InhabitationCandidate
-&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="#local-6989586621681146484"><span class="hs-identifier hs-var">cand_is_inhabitable</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146486"><span class="hs-identifier hs-var">rec_ts'</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146491"><span class="hs-identifier hs-var">amb_cs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[InhabitationCandidate]
</span><a href="#local-6989586621681146487"><span class="hs-identifier hs-var">cands</span></a></span><span>
</span><span id="line-1343"></span><span>           </span><span class="hs-comment">-- A strict argument type is inhabitable by a terminating value if</span><span>
</span><span id="line-1344"></span><span>           </span><span class="hs-comment">-- at least one InhabitationCandidate is inhabitable.</span><span>
</span><span id="line-1345"></span><span>    </span><span class="annot"><span class="annottext">Either Type (TyCon, Id, [InhabitationCandidate])
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1346"></span><span>           </span><span class="hs-comment">-- Either the type is trivially inhabited or we have exceeded the</span><span>
</span><span id="line-1347"></span><span>           </span><span class="hs-comment">-- recursion depth for some TyCon (so bail out and conservatively</span><span>
</span><span id="line-1348"></span><span>           </span><span class="hs-comment">-- claim the type is inhabited).</span><span>
</span><span id="line-1349"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1350"></span><span>    </span><span class="hs-comment">-- Checks if an InhabitationCandidate for a strict argument type:</span><span>
</span><span id="line-1351"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-1352"></span><span>    </span><span class="hs-comment">-- (1) Has satisfiable term and type constraints.</span><span>
</span><span id="line-1353"></span><span>    </span><span class="hs-comment">-- (2) Has 'nonVoid' strict argument types (we bail out of this</span><span>
</span><span id="line-1354"></span><span>    </span><span class="hs-comment">--     check if recursion is detected).</span><span>
</span><span id="line-1355"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-1356"></span><span>    </span><span class="hs-comment">-- See Note [Strict argument type constraints]</span><span>
</span><span id="line-1357"></span><span>    </span><span class="annot"><a href="#local-6989586621681146484"><span class="hs-identifier hs-type">cand_is_inhabitable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#RecTcChecker"><span class="hs-identifier hs-type">RecTcChecker</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-1358"></span><span>                        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1359"></span><span>    </span><span id="local-6989586621681146484"><span class="annot"><span class="annottext">cand_is_inhabitable :: RecTcChecker
-&gt; Delta
-&gt; InhabitationCandidate
-&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="#local-6989586621681146484"><span class="hs-identifier hs-var hs-var">cand_is_inhabitable</span></a></span></span><span> </span><span id="local-6989586621681146483"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146483"><span class="hs-identifier hs-var">rec_ts</span></a></span></span><span> </span><span id="local-6989586621681146482"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146482"><span class="hs-identifier hs-var">amb_cs</span></a></span></span><span>
</span><span id="line-1360"></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#InhabitationCandidate"><span class="hs-identifier hs-type">InhabitationCandidate</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_cs :: InhabitationCandidate -&gt; PmCts
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_cs"><span class="hs-identifier hs-var">ic_cs</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146481"><span class="annot"><span class="annottext">PmCts
</span><a href="#local-6989586621681146481"><span class="hs-identifier hs-var">new_cs</span></a></span></span><span>
</span><span id="line-1361"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_strict_arg_tys :: InhabitationCandidate -&gt; [Type]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#ic_strict_arg_tys"><span class="hs-identifier hs-var">ic_strict_arg_tys</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146480"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146480"><span class="hs-identifier hs-var">new_strict_arg_tys</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1362"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146479"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146479"><span class="hs-identifier hs-var">new_ty_cs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146478"><span class="annot"><span class="annottext">[TmCt]
</span><a href="#local-6989586621681146478"><span class="hs-identifier hs-var">new_tm_cs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PmCts -&gt; ([Type], [TmCt])
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#partitionTyTmCts"><span class="hs-identifier hs-var">partitionTyTmCts</span></a></span><span> </span><span class="annot"><span class="annottext">PmCts
</span><a href="#local-6989586621681146481"><span class="hs-identifier hs-var">new_cs</span></a></span><span>
</span><span id="line-1363"></span><span>        </span><span class="annot"><span class="annottext">(Maybe Delta -&gt; Bool)
-&gt; DsM (Maybe Delta) -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Delta -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">(DsM (Maybe Delta) -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool)
-&gt; DsM (Maybe Delta) -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; SatisfiabilityCheck -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#runSatisfiabilityCheck"><span class="hs-identifier hs-var">runSatisfiabilityCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146482"><span class="hs-identifier hs-var">amb_cs</span></a></span><span> </span><span class="annot"><span class="annottext">(SatisfiabilityCheck -&gt; DsM (Maybe Delta))
-&gt; SatisfiabilityCheck -&gt; DsM (Maybe Delta)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SatisfiabilityCheck] -&gt; SatisfiabilityCheck
forall a. Monoid a =&gt; [a] -&gt; a
</span><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var">mconcat</span></a></span><span>
</span><span id="line-1364"></span><span>          </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bag Type -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tyIsSatisfiable"><span class="hs-identifier hs-var">tyIsSatisfiable</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; Bag Type
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146479"><span class="hs-identifier hs-var">new_ty_cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1365"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag TmCt -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tmIsSatisfiable"><span class="hs-identifier hs-var">tmIsSatisfiable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TmCt] -&gt; Bag TmCt
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[TmCt]
</span><a href="#local-6989586621681146478"><span class="hs-identifier hs-var">new_tm_cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1366"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; [Type] -&gt; SatisfiabilityCheck
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tysAreNonVoid"><span class="hs-identifier hs-var">tysAreNonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681146483"><span class="hs-identifier hs-var">rec_ts</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146480"><span class="hs-identifier hs-var">new_strict_arg_tys</span></a></span><span>
</span><span id="line-1367"></span><span>          </span><span class="hs-special">]</span><span>
</span><span id="line-1368"></span><span>
</span><span id="line-1369"></span><span class="hs-comment">-- | @'definitelyInhabitedType' ty@ returns 'True' if @ty@ has at least one</span><span>
</span><span id="line-1370"></span><span class="hs-comment">-- constructor @C@ such that:</span><span>
</span><span id="line-1371"></span><span class="hs-comment">--</span><span>
</span><span id="line-1372"></span><span class="hs-comment">-- 1. @C@ has no equality constraints.</span><span>
</span><span id="line-1373"></span><span class="hs-comment">-- 2. @C@ has no strict argument types.</span><span>
</span><span id="line-1374"></span><span class="hs-comment">--</span><span>
</span><span id="line-1375"></span><span class="hs-comment">-- See the @Note [Strict argument type constraints]@.</span><span>
</span><span id="line-1376"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#definitelyInhabitedType"><span class="hs-identifier hs-type">definitelyInhabitedType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TyState"><span class="hs-identifier hs-type">TyState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1377"></span><span id="definitelyInhabitedType"><span class="annot"><span class="annottext">definitelyInhabitedType :: TyState -&gt; Type -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#definitelyInhabitedType"><span class="hs-identifier hs-var hs-var">definitelyInhabitedType</span></a></span></span><span> </span><span id="local-6989586621681146477"><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146477"><span class="hs-identifier hs-var">ty_st</span></a></span></span><span> </span><span id="local-6989586621681146476"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146476"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1378"></span><span>  </span><span id="local-6989586621681146475"><span class="annot"><span class="annottext">TopNormaliseTypeResult
</span><a href="#local-6989586621681146475"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyState -&gt; Type -&gt; DsM TopNormaliseTypeResult
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmTopNormaliseType"><span class="hs-identifier hs-var">pmTopNormaliseType</span></a></span><span> </span><span class="annot"><span class="annottext">TyState
</span><a href="#local-6989586621681146477"><span class="hs-identifier hs-var">ty_st</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146476"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1379"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool)
-&gt; Bool -&gt; IOEnv (Env DsGblEnv DsLclEnv) Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TopNormaliseTypeResult
</span><a href="#local-6989586621681146475"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1380"></span><span>           </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#HadRedexes"><span class="hs-identifier hs-type">HadRedexes</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681146474"><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146474"><span class="hs-identifier hs-var">cons</span></a></span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">((Type, DataCon, Type) -&gt; Bool) -&gt; [(Type, DataCon, Type)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="annot"><span class="annottext">(Type, DataCon, Type) -&gt; Bool
</span><a href="#local-6989586621681146473"><span class="hs-identifier hs-var">meets_criteria</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146474"><span class="hs-identifier hs-var">cons</span></a></span><span>
</span><span id="line-1381"></span><span>           </span><span class="annot"><span class="annottext">TopNormaliseTypeResult
</span><span class="hs-identifier">_</span></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1382"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1383"></span><span>    </span><span class="annot"><a href="#local-6989586621681146473"><span class="hs-identifier hs-type">meets_criteria</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1384"></span><span>    </span><span id="local-6989586621681146473"><span class="annot"><span class="annottext">meets_criteria :: (Type, DataCon, Type) -&gt; Bool
</span><a href="#local-6989586621681146473"><span class="hs-identifier hs-var hs-var">meets_criteria</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146472"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146472"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1385"></span><span>      </span><span class="annot"><span class="annottext">[EqSpec] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; [EqSpec]
</span><a href="GHC.Core.DataCon.html#dataConEqSpec"><span class="hs-identifier hs-var">dataConEqSpec</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146472"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-comment">-- (1)</span><span>
</span><span id="line-1386"></span><span>      </span><span class="annot"><span class="annottext">[HsImplBang] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; [HsImplBang]
</span><a href="GHC.Core.DataCon.html#dataConImplBangs"><span class="hs-identifier hs-var">dataConImplBangs</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146472"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- (2)</span><span>
</span><span id="line-1387"></span><span>
</span><span id="line-1388"></span><span class="hs-comment">{- Note [Strict argument type constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the ConVar case of clause processing, each conlike K traditionally
generates two different forms of constraints:

* A term constraint (e.g., x ~ K y1 ... yn)
* Type constraints from the conlike's context (e.g., if K has type
  forall bs. Q =&gt; s1 .. sn -&gt; T tys, then Q would be its type constraints)

As it turns out, these alone are not enough to detect a certain class of
unreachable code. Consider the following example (adapted from #15305):

  data K = K1 | K2 !Void

  f :: K -&gt; ()
  f K1 = ()

Even though `f` doesn't match on `K2`, `f` is exhaustive in its patterns. Why?
Because it's impossible to construct a terminating value of type `K` using the
`K2` constructor, and thus it's impossible for `f` to ever successfully match
on `K2`.

The reason is because `K2`'s field of type `Void` is //strict//. Because there
are no terminating values of type `Void`, any attempt to construct something
using `K2` will immediately loop infinitely or throw an exception due to the
strictness annotation. (If the field were not strict, then `f` could match on,
say, `K2 undefined` or `K2 (let x = x in x)`.)

Since neither the term nor type constraints mentioned above take strict
argument types into account, we make use of the `nonVoid` function to
determine whether a strict type is inhabitable by a terminating value or not.
We call this the &quot;inhabitation test&quot;.

`nonVoid ty` returns True when either:
1. `ty` has at least one InhabitationCandidate for which both its term and type
   constraints are satisfiable, and `nonVoid` returns `True` for all of the
   strict argument types in that InhabitationCandidate.
2. We're unsure if it's inhabited by a terminating value.

`nonVoid ty` returns False when `ty` is definitely uninhabited by anything
(except bottom). Some examples:

* `nonVoid Void` returns False, since Void has no InhabitationCandidates.
  (This is what lets us discard the `K2` constructor in the earlier example.)
* `nonVoid (Int :~: Int)` returns True, since it has an InhabitationCandidate
  (through the Refl constructor), and its term constraint (x ~ Refl) and
  type constraint (Int ~ Int) are satisfiable.
* `nonVoid (Int :~: Bool)` returns False. Although it has an
  InhabitationCandidate (by way of Refl), its type constraint (Int ~ Bool) is
  not satisfiable.
* Given the following definition of `MyVoid`:

    data MyVoid = MkMyVoid !Void

  `nonVoid MyVoid` returns False. The InhabitationCandidate for the MkMyVoid
  constructor contains Void as a strict argument type, and since `nonVoid Void`
  returns False, that InhabitationCandidate is discarded, leaving no others.
* Whether or not a type is inhabited is undecidable in general.
  See Note [Fuel for the inhabitation test].
* For some types, inhabitation is evident immediately and we don't need to
  perform expensive tests. See Note [Types that are definitely inhabitable].

Note [Fuel for the inhabitation test]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Whether or not a type is inhabited is undecidable in general. As a result, we
can run into infinite loops in `nonVoid`. Therefore, we adopt a fuel-based
approach to prevent that.

Consider the following example:

  data Abyss = MkAbyss !Abyss
  stareIntoTheAbyss :: Abyss -&gt; a
  stareIntoTheAbyss x = case x of {}

In principle, stareIntoTheAbyss is exhaustive, since there is no way to
construct a terminating value using MkAbyss. However, both the term and type
constraints for MkAbyss are satisfiable, so the only way one could determine
that MkAbyss is unreachable is to check if `nonVoid Abyss` returns False.
There is only one InhabitationCandidate for Abyss&#8212;MkAbyss&#8212;and both its term
and type constraints are satisfiable, so we'd need to check if `nonVoid Abyss`
returns False... and now we've entered an infinite loop!

To avoid this sort of conundrum, `nonVoid` uses a simple test to detect the
presence of recursive types (through `checkRecTc`), and if recursion is
detected, we bail out and conservatively assume that the type is inhabited by
some terminating value. This avoids infinite loops at the expense of making
the coverage checker incomplete with respect to functions like
stareIntoTheAbyss above. Then again, the same problem occurs with recursive
newtypes, like in the following code:

  newtype Chasm = MkChasm Chasm
  gazeIntoTheChasm :: Chasm -&gt; a
  gazeIntoTheChasm x = case x of {} -- Erroneously warned as non-exhaustive

So this limitation is somewhat understandable.

Note that even with this recursion detection, there is still a possibility that
`nonVoid` can run in exponential time. Consider the following data type:

  data T = MkT !T !T !T

If we call `nonVoid` on each of its fields, that will require us to once again
check if `MkT` is inhabitable in each of those three fields, which in turn will
require us to check if `MkT` is inhabitable again... As you can see, the
branching factor adds up quickly, and if the recursion depth limit is, say,
100, then `nonVoid T` will effectively take forever.

To mitigate this, we check the branching factor every time we are about to call
`nonVoid` on a list of strict argument types. If the branching factor exceeds 1
(i.e., if there is potential for exponential runtime), then we limit the
maximum recursion depth to 1 to mitigate the problem. If the branching factor
is exactly 1 (i.e., we have a linear chain instead of a tree), then it's okay
to stick with a larger maximum recursion depth.

In #17977 we saw that the defaultRecTcMaxBound (100 at the time of writing) was
too large and had detrimental effect on performance of the coverage checker.
Given that we only commit to a best effort anyway, we decided to substantially
decrement the recursion depth to 3, at the cost of precision in some edge cases
like

  data Nat = Z | S Nat
  data Down :: Nat -&gt; Type where
    Down :: !(Down n) -&gt; Down (S n)
  f :: Down (S (S (S (S (S Z))))) -&gt; ()
  f x = case x of {}

Since the coverage won't bother to instantiate Down 4 levels deep to see that it
is in fact uninhabited, it will emit a inexhaustivity warning for the case.

Note [Types that are definitely inhabitable]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another microoptimization applies to data types like this one:

  data S a = S ![a] !T

Even though there is a strict field of type [a], it's quite silly to call
nonVoid on it, since it's &quot;obvious&quot; that it is inhabitable. To make this
intuition formal, we say that a type is definitely inhabitable (DI) if:

  * It has at least one constructor C such that:
    1. C has no equality constraints (since they might be unsatisfiable)
    2. C has no strict argument types (since they might be uninhabitable)

It's relatively cheap to check if a type is DI, so before we call `nonVoid`
on a list of strict argument types, we filter out all of the DI ones.
-}</span><span>
</span><span id="line-1534"></span><span>
</span><span id="line-1535"></span><span class="hs-comment">--------------------------------------------</span><span>
</span><span id="line-1536"></span><span class="hs-comment">-- * Providing positive evidence for a Delta</span><span>
</span><span id="line-1537"></span><span>
</span><span id="line-1538"></span><span class="hs-comment">-- | @provideEvidence vs n delta@ returns a list of</span><span>
</span><span id="line-1539"></span><span class="hs-comment">-- at most @n@ (but perhaps empty) refinements of @delta@ that instantiate</span><span>
</span><span id="line-1540"></span><span class="hs-comment">-- @vs@ to compatible constructor applications or wildcards.</span><span>
</span><span id="line-1541"></span><span class="hs-comment">-- Negative information is only retained if literals are involved or when</span><span>
</span><span id="line-1542"></span><span class="hs-comment">-- for recursive GADTs.</span><span>
</span><span id="line-1543"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#provideEvidence"><span class="hs-identifier hs-type">provideEvidence</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1544"></span><span id="provideEvidence"><span class="annot"><span class="annottext">provideEvidence :: [Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#provideEvidence"><span class="hs-identifier hs-var hs-var">provideEvidence</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146468"><span class="hs-identifier hs-var">go</span></a></span><span>
</span><span id="line-1545"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1546"></span><span>    </span><span id="local-6989586621681146468"><span class="annot"><span class="annottext">go :: [Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146468"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span>      </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Delta
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1547"></span><span>    </span><span class="annot"><a href="#local-6989586621681146468"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681146457"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146457"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146457"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1548"></span><span>    </span><span class="annot"><a href="#local-6989586621681146468"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146456"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146456"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681146455"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146455"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681146454"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146454"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681146453"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146453"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1549"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-var">tracePm</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;provideEvidence&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146456"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146455"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146453"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146454"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1550"></span><span>      </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#VI"><span class="hs-identifier hs-type">VI</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681146452"><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146452"><span class="hs-identifier hs-var">pos</span></a></span></span><span> </span><span id="local-6989586621681146451"><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146451"><span class="hs-identifier hs-var">neg</span></a></span></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; DsM VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#initLookupVarInfo"><span class="hs-identifier hs-var">initLookupVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146453"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146456"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-1551"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146452"><span class="hs-identifier hs-var">pos</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1552"></span><span>        </span><span class="annot"><span class="annottext">(PmAltCon, [Id], [Id])
</span><span class="hs-identifier">_</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1553"></span><span>          </span><span class="hs-comment">-- All solutions must be valid at once. Try to find candidates for their</span><span>
</span><span id="line-1554"></span><span>          </span><span class="hs-comment">-- fields. Example:</span><span>
</span><span id="line-1555"></span><span>          </span><span class="hs-comment">--   f x@(Just _) True = case x of SomePatSyn _ -&gt; ()</span><span>
</span><span id="line-1556"></span><span>          </span><span class="hs-comment">-- after this clause, we want to report that</span><span>
</span><span id="line-1557"></span><span>          </span><span class="hs-comment">--   * @f Nothing _@ is uncovered</span><span>
</span><span id="line-1558"></span><span>          </span><span class="hs-comment">--   * @f x False@ is uncovered</span><span>
</span><span id="line-1559"></span><span>          </span><span class="hs-comment">-- where @x@ will have two possibly compatible solutions, @Just y@ for</span><span>
</span><span id="line-1560"></span><span>          </span><span class="hs-comment">-- some @y@ and @SomePatSyn z@ for some @z@. We must find evidence for @y@</span><span>
</span><span id="line-1561"></span><span>          </span><span class="hs-comment">-- and @z@ that is valid at the same time. These constitute arg_vas below.</span><span>
</span><span id="line-1562"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146449"><span class="annot"><span class="annottext">arg_vas :: [Id]
</span><a href="#local-6989586621681146449"><span class="hs-identifier hs-var hs-var">arg_vas</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((PmAltCon, [Id], [Id]) -&gt; [Id])
-&gt; [(PmAltCon, [Id], [Id])] -&gt; [Id]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681146447"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146447"><span class="hs-identifier hs-var">_cl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146446"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146446"><span class="hs-identifier hs-var">_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146445"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146445"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146445"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(PmAltCon, [Id], [Id])]
</span><a href="#local-6989586621681146452"><span class="hs-identifier hs-var">pos</span></a></span><span>
</span><span id="line-1563"></span><span>          </span><span class="annot"><span class="annottext">[Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146468"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146449"><span class="hs-identifier hs-var">arg_vas</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146455"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146454"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146453"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-1564"></span><span>        </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1565"></span><span>          </span><span class="hs-comment">-- When there are literals involved, just print negative info</span><span>
</span><span id="line-1566"></span><span>          </span><span class="hs-comment">-- instead of listing missed constructors</span><span>
</span><span id="line-1567"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[PmLit] -&gt; Bool
forall a. [a] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#notNull"><span class="hs-identifier hs-var">notNull</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">PmLit
</span><a href="#local-6989586621681146444"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltLit"><span class="hs-identifier hs-type">PmAltLit</span></a></span><span> </span><span id="local-6989586621681146444"><span class="annot"><span class="annottext">PmLit
</span><a href="#local-6989586621681146444"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PmAltConSet -&gt; [PmAltCon]
</span><a href="GHC.HsToCore.PmCheck.Types.html#pmAltConSetElems"><span class="hs-identifier hs-var">pmAltConSetElems</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltConSet
</span><a href="#local-6989586621681146451"><span class="hs-identifier hs-var">neg</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1568"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146468"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146455"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146454"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146453"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-1569"></span><span>        </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146442"><span class="hs-identifier hs-var">try_instantiate</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146456"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146455"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146454"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146453"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-1570"></span><span>
</span><span id="line-1571"></span><span>    </span><span class="hs-comment">-- | Tries to instantiate a variable by possibly following the chain of</span><span>
</span><span id="line-1572"></span><span>    </span><span class="hs-comment">-- newtypes and then instantiating to all ConLikes of the wrapped type's</span><span>
</span><span id="line-1573"></span><span>    </span><span class="hs-comment">-- minimal residual COMPLETE set.</span><span>
</span><span id="line-1574"></span><span>    </span><span class="annot"><a href="#local-6989586621681146442"><span class="hs-identifier hs-type">try_instantiate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1575"></span><span>    </span><span class="hs-comment">-- Convention: x binds the outer constructor in the chain, y the inner one.</span><span>
</span><span id="line-1576"></span><span>    </span><span id="local-6989586621681146442"><span class="annot"><span class="annottext">try_instantiate :: Id -&gt; [Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146442"><span class="hs-identifier hs-var hs-var">try_instantiate</span></a></span></span><span> </span><span id="local-6989586621681146441"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146441"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146440"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146440"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621681146439"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146439"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681146438"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146438"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1577"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681146437"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146437"><span class="hs-identifier hs-var">_src_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146436"><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146436"><span class="hs-identifier hs-var">dcs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146435"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146435"><span class="hs-identifier hs-var">core_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TopNormaliseTypeResult -&gt; (Type, [(Type, DataCon, Type)], Type)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tntrGuts"><span class="hs-identifier hs-var">tntrGuts</span></a></span><span> </span><span class="annot"><span class="annottext">(TopNormaliseTypeResult -&gt; (Type, [(Type, DataCon, Type)], Type))
-&gt; DsM TopNormaliseTypeResult
-&gt; IOEnv
     (Env DsGblEnv DsLclEnv) (Type, [(Type, DataCon, Type)], Type)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyState -&gt; Type -&gt; DsM TopNormaliseTypeResult
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmTopNormaliseType"><span class="hs-identifier hs-var">pmTopNormaliseType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; TyState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_ty_st"><span class="hs-identifier hs-var hs-var">delta_ty_st</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146438"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146441"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1578"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146427"><span class="annot"><span class="annottext">build_newtype :: (Id, Delta) -&gt; (a, DataCon, Type) -&gt; MaybeT DsM (Id, Delta)
</span><a href="#local-6989586621681146427"><span class="hs-identifier hs-var hs-var">build_newtype</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146426"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146426"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146425"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146425"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146424"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681146424"><span class="hs-identifier hs-var">_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146423"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146423"><span class="hs-identifier hs-var">dc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146422"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146422"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1579"></span><span>            </span><span id="local-6989586621681146421"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146421"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM Id -&gt; MaybeT DsM Id
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(DsM Id -&gt; MaybeT DsM Id) -&gt; DsM Id -&gt; MaybeT DsM Id
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-var">mkPmId</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146422"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-1580"></span><span>            </span><span class="hs-comment">-- Newtypes don't have existentials (yet?!), so passing an empty</span><span>
</span><span id="line-1581"></span><span>            </span><span class="hs-comment">-- list as ex_tvs.</span><span>
</span><span id="line-1582"></span><span>            </span><span id="local-6989586621681146420"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146420"><span class="hs-identifier hs-var">delta'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addConCt"><span class="hs-identifier hs-var">addConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146425"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146426"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; PmAltCon
</span><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-var">PmAltConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; ConLike
</span><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-var">RealDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146423"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146421"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1583"></span><span>            </span><span class="annot"><span class="annottext">(Id, Delta) -&gt; MaybeT DsM (Id, Delta)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146421"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146420"><span class="hs-identifier hs-var">delta'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1584"></span><span>      </span><span class="annot"><span class="annottext">MaybeT DsM (Id, Delta)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) (Maybe (Id, Delta))
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Id, Delta) -&gt; (Type, DataCon, Type) -&gt; MaybeT DsM (Id, Delta))
-&gt; (Id, Delta) -&gt; [(Type, DataCon, Type)] -&gt; MaybeT DsM (Id, Delta)
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, Delta) -&gt; (Type, DataCon, Type) -&gt; MaybeT DsM (Id, Delta)
forall {a}.
(Id, Delta) -&gt; (a, DataCon, Type) -&gt; MaybeT DsM (Id, Delta)
</span><a href="#local-6989586621681146427"><span class="hs-identifier hs-var">build_newtype</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146441"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146438"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Type, DataCon, Type)]
</span><a href="#local-6989586621681146436"><span class="hs-identifier hs-var">dcs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) (Maybe (Id, Delta))
-&gt; (Maybe (Id, Delta) -&gt; DsM [Delta]) -&gt; DsM [Delta]
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-glyph">case</span><span>
</span><span id="line-1585"></span><span>        </span><span class="annot"><span class="annottext">Maybe (Id, Delta)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1586"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146419"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146419"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146418"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146418"><span class="hs-identifier hs-var">newty_delta</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1587"></span><span>          </span><span class="hs-comment">-- Pick a COMPLETE set and instantiate it (n at max). Take care of &#8869;.</span><span>
</span><span id="line-1588"></span><span>          </span><span id="local-6989586621681146417"><span class="annot"><span class="annottext">PossibleMatches
</span><a href="#local-6989586621681146417"><span class="hs-identifier hs-var">pm</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">VarInfo -&gt; PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#vi_cache"><span class="hs-identifier hs-var hs-var">vi_cache</span></a></span><span> </span><span class="annot"><span class="annottext">(VarInfo -&gt; PossibleMatches)
-&gt; DsM VarInfo -&gt; IOEnv (Env DsGblEnv DsLclEnv) PossibleMatches
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; DsM VarInfo
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#initLookupVarInfo"><span class="hs-identifier hs-var">initLookupVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146418"><span class="hs-identifier hs-var">newty_delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146419"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-1589"></span><span>          </span><span id="local-6989586621681146416"><span class="annot"><span class="annottext">Maybe ConLikeSet
</span><a href="#local-6989586621681146416"><span class="hs-identifier hs-var">mb_cls</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; PossibleMatches -&gt; DsM (Maybe ConLikeSet)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pickMinimalCompleteSet"><span class="hs-identifier hs-var">pickMinimalCompleteSet</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146418"><span class="hs-identifier hs-var">newty_delta</span></a></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="#local-6989586621681146417"><span class="hs-identifier hs-var">pm</span></a></span><span>
</span><span id="line-1590"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ConLikeSet -&gt; [ConLike]
forall a. UniqDSet a -&gt; [a]
</span><a href="GHC.Types.Unique.DSet.html#uniqDSetToList"><span class="hs-identifier hs-var">uniqDSetToList</span></a></span><span> </span><span class="annot"><span class="annottext">(ConLikeSet -&gt; [ConLike]) -&gt; Maybe ConLikeSet -&gt; Maybe [ConLike]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ConLikeSet
</span><a href="#local-6989586621681146416"><span class="hs-identifier hs-var">mb_cls</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1591"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146414"><span class="annot"><span class="annottext">cls :: [ConLike]
</span><a href="#local-6989586621681146414"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike
</span><span class="hs-identifier">_</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[ConLike]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type -&gt; [Id] -&gt; Int -&gt; Delta -&gt; [ConLike] -&gt; DsM [Delta]
</span><a href="#local-6989586621681146413"><span class="hs-identifier hs-var">instantiate_cons</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146419"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146435"><span class="hs-identifier hs-var">core_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146440"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146439"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146418"><span class="hs-identifier hs-var">newty_delta</span></a></span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681146414"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-1592"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#canDiverge"><span class="hs-identifier hs-var">canDiverge</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146418"><span class="hs-identifier hs-var">newty_delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146419"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1593"></span><span>            </span><span class="hs-comment">-- Either &#8869; is still possible (think Void) or there are no COMPLETE</span><span>
</span><span id="line-1594"></span><span>            </span><span class="hs-comment">-- sets available, so we can assume it's inhabited</span><span>
</span><span id="line-1595"></span><span>            </span><span class="annot"><span class="annottext">Maybe [ConLike]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146468"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146440"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146439"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146418"><span class="hs-identifier hs-var">newty_delta</span></a></span><span>
</span><span id="line-1596"></span><span>
</span><span id="line-1597"></span><span>    </span><span class="annot"><a href="#local-6989586621681146413"><span class="hs-identifier hs-type">instantiate_cons</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1598"></span><span>    </span><span id="local-6989586621681146413"><span class="annot"><span class="annottext">instantiate_cons :: Id -&gt; Type -&gt; [Id] -&gt; Int -&gt; Delta -&gt; [ConLike] -&gt; DsM [Delta]
</span><a href="#local-6989586621681146413"><span class="hs-identifier hs-var hs-var">instantiate_cons</span></a></span></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Delta
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-special">[</span><span class="hs-special">]</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1599"></span><span>    </span><span class="annot"><a href="#local-6989586621681146413"><span class="hs-identifier hs-var">instantiate_cons</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Delta
</span><span class="hs-identifier">_</span></span><span>     </span><span class="annot"><span class="annottext">[ConLike]
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1600"></span><span>    </span><span class="annot"><a href="#local-6989586621681146413"><span class="hs-identifier hs-var">instantiate_cons</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681146412"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146412"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681146411"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146411"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621681146410"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146410"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681146409"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146409"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1601"></span><span>      </span><span class="hs-comment">-- We don't want to expose users to GHC-specific constructors for Int etc.</span><span>
</span><span id="line-1602"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">((TyCon, [Type]) -&gt; Bool) -&gt; Maybe (TyCon, [Type]) -&gt; Maybe Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#isTyConTriviallyInhabited"><span class="hs-identifier hs-var">isTyConTriviallyInhabited</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; Bool)
-&gt; ((TyCon, [Type]) -&gt; TyCon) -&gt; (TyCon, [Type]) -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(TyCon, [Type]) -&gt; TyCon
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146412"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Bool -&gt; Maybe Bool -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Maybe Bool
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1603"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146468"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146411"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146410"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146409"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-1604"></span><span>    </span><span class="annot"><a href="#local-6989586621681146413"><span class="hs-identifier hs-var">instantiate_cons</span></a></span><span> </span><span id="local-6989586621681146408"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146408"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146407"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146407"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681146406"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146406"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621681146405"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146405"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681146404"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146404"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146403"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146403"><span class="hs-identifier hs-var">cl</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681146402"><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681146402"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1605"></span><span>      </span><span id="local-6989586621681146401"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146401"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DsM FamInstEnvs
</span><a href="GHC.HsToCore.Monad.html#dsGetFamInstEnvs"><span class="hs-identifier hs-var">dsGetFamInstEnvs</span></a></span><span>
</span><span id="line-1606"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs -&gt; Type -&gt; ConLike -&gt; Maybe [Type]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#guessConLikeUnivTyArgsFromResTy"><span class="hs-identifier hs-var">guessConLikeUnivTyArgsFromResTy</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681146401"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146407"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146403"><span class="hs-identifier hs-var">cl</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1607"></span><span>        </span><span class="annot"><span class="annottext">Maybe [Type]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146404"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- No idea how to refine this one, so just finish off with a wildcard</span><span>
</span><span id="line-1608"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146400"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146400"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1609"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621681146399"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146399"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146398"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146398"><span class="hs-identifier hs-var">arg_vars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146397"><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146397"><span class="hs-identifier hs-var">new_ty_cs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146396"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146396"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; ConLike -&gt; DsM ([Id], [Id], Bag Type, [Type])
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkOneConFull"><span class="hs-identifier hs-var">mkOneConFull</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146400"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146403"><span class="hs-identifier hs-var">cl</span></a></span><span>
</span><span id="line-1610"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146395"><span class="annot"><span class="annottext">new_tm_cs :: Bag TmCt
</span><a href="#local-6989586621681146395"><span class="hs-identifier hs-var hs-var">new_tm_cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TmCt -&gt; Bag TmCt
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; TmCt
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#TmConCt"><span class="hs-identifier hs-var">TmConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146408"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; PmAltCon
</span><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-var">PmAltConLike</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146403"><span class="hs-identifier hs-var">cl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146399"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146398"><span class="hs-identifier hs-var">arg_vars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1611"></span><span>          </span><span class="hs-comment">-- Now check satifiability</span><span>
</span><span id="line-1612"></span><span>          </span><span id="local-6989586621681146393"><span class="annot"><span class="annottext">Maybe Delta
</span><a href="#local-6989586621681146393"><span class="hs-identifier hs-var">mb_delta</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Bag Type -&gt; Bag TmCt -&gt; [Type] -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pmIsSatisfiable"><span class="hs-identifier hs-var">pmIsSatisfiable</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146404"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146397"><span class="hs-identifier hs-var">new_ty_cs</span></a></span><span> </span><span class="annot"><span class="annottext">Bag TmCt
</span><a href="#local-6989586621681146395"><span class="hs-identifier hs-var">new_tm_cs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146396"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span>
</span><span id="line-1613"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-var">tracePm</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;instantiate_cons&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146408"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-1614"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146408"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1615"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146407"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1616"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ConLike -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681146403"><span class="hs-identifier hs-var">cl</span></a></span><span>
</span><span id="line-1617"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146400"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-1618"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag TmCt -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag TmCt
</span><a href="#local-6989586621681146395"><span class="hs-identifier hs-var">new_tm_cs</span></a></span><span>
</span><span id="line-1619"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Type
</span><a href="#local-6989586621681146397"><span class="hs-identifier hs-var">new_ty_cs</span></a></span><span>
</span><span id="line-1620"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146396"><span class="hs-identifier hs-var">strict_arg_tys</span></a></span><span>
</span><span id="line-1621"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146404"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-1622"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Delta -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Delta
</span><a href="#local-6989586621681146393"><span class="hs-identifier hs-var">mb_delta</span></a></span><span>
</span><span id="line-1623"></span><span>                                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146405"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1624"></span><span>          </span><span id="local-6989586621681146392"><span class="annot"><span class="annottext">[Delta]
</span><a href="#local-6989586621681146392"><span class="hs-identifier hs-var">con_deltas</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Delta
</span><a href="#local-6989586621681146393"><span class="hs-identifier hs-var">mb_delta</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1625"></span><span>            </span><span class="annot"><span class="annottext">Maybe Delta
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1626"></span><span>            </span><span class="hs-comment">-- NB: We don't prepend arg_vars as we don't have any evidence on</span><span>
</span><span id="line-1627"></span><span>            </span><span class="hs-comment">-- them and we only want to split once on a data type. They are</span><span>
</span><span id="line-1628"></span><span>            </span><span class="hs-comment">-- inhabited, otherwise pmIsSatisfiable would have refuted.</span><span>
</span><span id="line-1629"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146391"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146391"><span class="hs-identifier hs-var">delta'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Int -&gt; Delta -&gt; DsM [Delta]
</span><a href="#local-6989586621681146468"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146406"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146405"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146391"><span class="hs-identifier hs-var">delta'</span></a></span><span>
</span><span id="line-1630"></span><span>          </span><span id="local-6989586621681146390"><span class="annot"><span class="annottext">[Delta]
</span><a href="#local-6989586621681146390"><span class="hs-identifier hs-var">other_cons_deltas</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type -&gt; [Id] -&gt; Int -&gt; Delta -&gt; [ConLike] -&gt; DsM [Delta]
</span><a href="#local-6989586621681146413"><span class="hs-identifier hs-var">instantiate_cons</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146408"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146407"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146406"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146405"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Delta]
</span><a href="#local-6989586621681146392"><span class="hs-identifier hs-var">con_deltas</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146404"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">[ConLike]
</span><a href="#local-6989586621681146402"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-1631"></span><span>          </span><span class="annot"><span class="annottext">[Delta] -&gt; DsM [Delta]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Delta]
</span><a href="#local-6989586621681146392"><span class="hs-identifier hs-var">con_deltas</span></a></span><span> </span><span class="annot"><span class="annottext">[Delta] -&gt; [Delta] -&gt; [Delta]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Delta]
</span><a href="#local-6989586621681146390"><span class="hs-identifier hs-var">other_cons_deltas</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1632"></span><span>
</span><span id="line-1633"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#pickMinimalCompleteSet"><span class="hs-identifier hs-type">pickMinimalCompleteSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PossibleMatches"><span class="hs-identifier hs-type">PossibleMatches</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#ConLikeSet"><span class="hs-identifier hs-type">ConLikeSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1634"></span><span id="pickMinimalCompleteSet"><span class="annot"><span class="annottext">pickMinimalCompleteSet :: Delta -&gt; PossibleMatches -&gt; DsM (Maybe ConLikeSet)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#pickMinimalCompleteSet"><span class="hs-identifier hs-var hs-var">pickMinimalCompleteSet</span></a></span></span><span> </span><span class="annot"><span class="annottext">Delta
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">PossibleMatches
</span><a href="GHC.HsToCore.PmCheck.Types.html#NoPM"><span class="hs-identifier hs-var">NoPM</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe ConLikeSet -&gt; DsM (Maybe ConLikeSet)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ConLikeSet
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1635"></span><span class="hs-comment">-- TODO: First prune sets with type info in delta. But this is good enough for</span><span>
</span><span id="line-1636"></span><span class="hs-comment">-- now and less costly. See #17386.</span><span>
</span><span id="line-1637"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#pickMinimalCompleteSet"><span class="hs-identifier hs-var">pickMinimalCompleteSet</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PM"><span class="hs-identifier hs-type">PM</span></a></span><span> </span><span id="local-6989586621681146389"><span class="annot"><span class="annottext">NonEmpty ConLikeSet
</span><a href="#local-6989586621681146389"><span class="hs-identifier hs-var">clss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1638"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-var">tracePm</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;pickMinimalCompleteSet&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ConLikeSet] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">([ConLikeSet] -&gt; SDoc) -&gt; [ConLikeSet] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty ConLikeSet -&gt; [ConLikeSet]
forall a. NonEmpty a -&gt; [a]
</span><a href="../../base/src/Data.List.NonEmpty.html#toList"><span class="hs-identifier hs-var">NonEmpty.toList</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty ConLikeSet
</span><a href="#local-6989586621681146389"><span class="hs-identifier hs-var">clss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1639"></span><span>  </span><span class="annot"><span class="annottext">Maybe ConLikeSet -&gt; DsM (Maybe ConLikeSet)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLikeSet -&gt; Maybe ConLikeSet
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ConLikeSet -&gt; ConLikeSet -&gt; Ordering)
-&gt; NonEmpty ConLikeSet -&gt; ConLikeSet
forall (t :: * -&gt; *) a.
Foldable t =&gt;
(a -&gt; a -&gt; Ordering) -&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#minimumBy"><span class="hs-identifier hs-var">minimumBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ConLikeSet -&gt; Int) -&gt; ConLikeSet -&gt; ConLikeSet -&gt; Ordering
forall a b. Ord a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Ordering
</span><a href="../../base/src/Data.Ord.html#comparing"><span class="hs-identifier hs-var">comparing</span></a></span><span> </span><span class="annot"><span class="annottext">ConLikeSet -&gt; Int
forall a. UniqDSet a -&gt; Int
</span><a href="GHC.Types.Unique.DSet.html#sizeUniqDSet"><span class="hs-identifier hs-var">sizeUniqDSet</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">NonEmpty ConLikeSet
</span><a href="#local-6989586621681146389"><span class="hs-identifier hs-var">clss</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1640"></span><span>
</span><span id="line-1641"></span><span class="hs-comment">-- | Finds a representant of the semantic equality class of the given @e@.</span><span>
</span><span id="line-1642"></span><span class="hs-comment">-- Which is the @x@ of a @let x = e'@ constraint (with @e@ semantically</span><span>
</span><span id="line-1643"></span><span class="hs-comment">-- equivalent to @e'@) we encountered earlier, or a fresh identifier if</span><span>
</span><span id="line-1644"></span><span class="hs-comment">-- there weren't any such constraints.</span><span>
</span><span id="line-1645"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#representCoreExpr"><span class="hs-identifier hs-type">representCoreExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1646"></span><span id="representCoreExpr"><span class="annot"><span class="annottext">representCoreExpr :: Delta -&gt; CoreExpr -&gt; DsM (Delta, Id)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#representCoreExpr"><span class="hs-identifier hs-var hs-var">representCoreExpr</span></a></span></span><span> </span><span id="local-6989586621681146385"><span class="annot"><span class="annottext">delta :: Delta
</span><a href="#local-6989586621681146385"><span class="hs-identifier hs-var">delta</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#MkDelta"><span class="hs-identifier hs-type">MkDelta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: Delta -&gt; TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146384"><span class="annot"><span class="annottext">ts :: TmState
</span><a href="#local-6989586621681146384"><span class="hs-identifier hs-var">ts</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#TmSt"><span class="hs-identifier hs-type">TmSt</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ts_reps :: TmState -&gt; CoreMap Id
</span><a href="GHC.HsToCore.PmCheck.Types.html#ts_reps"><span class="hs-identifier hs-var">ts_reps</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681146382"><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146382"><span class="hs-identifier hs-var">reps</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span> </span><span id="local-6989586621681146381"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146381"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-1647"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146380"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146380"><span class="hs-identifier hs-var">rep</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreMap Id -&gt; CoreExpr -&gt; Maybe Id
forall a. CoreMap a -&gt; CoreExpr -&gt; Maybe a
</span><a href="GHC.Core.Map.html#lookupCoreMap"><span class="hs-identifier hs-var">lookupCoreMap</span></a></span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146382"><span class="hs-identifier hs-var">reps</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146381"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Delta, Id) -&gt; DsM (Delta, Id)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146385"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146380"><span class="hs-identifier hs-var">rep</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1648"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1649"></span><span>      </span><span id="local-6989586621681146378"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146378"><span class="hs-identifier hs-var">rep</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-var">mkPmId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146381"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1650"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146377"><span class="annot"><span class="annottext">reps' :: CoreMap Id
</span><a href="#local-6989586621681146377"><span class="hs-identifier hs-var hs-var">reps'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreMap Id -&gt; CoreExpr -&gt; Id -&gt; CoreMap Id
forall a. CoreMap a -&gt; CoreExpr -&gt; a -&gt; CoreMap a
</span><a href="GHC.Core.Map.html#extendCoreMap"><span class="hs-identifier hs-var">extendCoreMap</span></a></span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146382"><span class="hs-identifier hs-var">reps</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146381"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146378"><span class="hs-identifier hs-var">rep</span></a></span><span>
</span><span id="line-1651"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146375"><span class="annot"><span class="annottext">delta' :: Delta
</span><a href="#local-6989586621681146375"><span class="hs-identifier hs-var hs-var">delta'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146385"><span class="hs-identifier hs-var">delta</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">delta_tm_st :: TmState
</span><a href="GHC.HsToCore.PmCheck.Types.html#delta_tm_st"><span class="hs-identifier hs-var">delta_tm_st</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TmState
</span><a href="#local-6989586621681146384"><span class="hs-identifier hs-var">ts</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ts_reps :: CoreMap Id
</span><a href="GHC.HsToCore.PmCheck.Types.html#ts_reps"><span class="hs-identifier hs-var">ts_reps</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreMap Id
</span><a href="#local-6989586621681146377"><span class="hs-identifier hs-var">reps'</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1652"></span><span>      </span><span class="annot"><span class="annottext">(Delta, Id) -&gt; DsM (Delta, Id)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146375"><span class="hs-identifier hs-var">delta'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146378"><span class="hs-identifier hs-var">rep</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1653"></span><span>
</span><span id="line-1654"></span><span class="hs-comment">-- | Inspects a 'PmCoreCt' @let x = e@ by recording constraints for @x@ based</span><span>
</span><span id="line-1655"></span><span class="hs-comment">-- on the shape of the 'CoreExpr' @e@. Examples:</span><span>
</span><span id="line-1656"></span><span class="hs-comment">--</span><span>
</span><span id="line-1657"></span><span class="hs-comment">--   * For @let x = Just (42, 'z')@ we want to record the</span><span>
</span><span id="line-1658"></span><span class="hs-comment">--     constraints @x ~ Just a, a ~ (b, c), b ~ 42, c ~ 'z'@.</span><span>
</span><span id="line-1659"></span><span class="hs-comment">--     See 'data_con_app'.</span><span>
</span><span id="line-1660"></span><span class="hs-comment">--   * For @let x = unpackCString# &quot;tmp&quot;@ we want to record the literal</span><span>
</span><span id="line-1661"></span><span class="hs-comment">--     constraint @x ~ &quot;tmp&quot;@.</span><span>
</span><span id="line-1662"></span><span class="hs-comment">--   * For @let x = I# 42@ we want the literal constraint @x ~ 42@. Similar</span><span>
</span><span id="line-1663"></span><span class="hs-comment">--     for other literals. See 'coreExprAsPmLit'.</span><span>
</span><span id="line-1664"></span><span class="hs-comment">--   * Finally, if we have @let x = e@ and we already have seen @let y = e@, we</span><span>
</span><span id="line-1665"></span><span class="hs-comment">--     want to record @x ~ y@.</span><span>
</span><span id="line-1666"></span><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#addCoreCt"><span class="hs-identifier hs-type">addCoreCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span>
</span><span id="line-1667"></span><span id="addCoreCt"><span class="annot"><span class="annottext">addCoreCt :: Delta -&gt; Id -&gt; CoreExpr -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addCoreCt"><span class="hs-identifier hs-var hs-var">addCoreCt</span></a></span></span><span> </span><span id="local-6989586621681146374"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146374"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span id="local-6989586621681146373"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146373"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146372"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146372"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1668"></span><span>  </span><span id="local-6989586621681146371"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681146371"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1669"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146369"><span class="annot"><span class="annottext">e' :: CoreExpr
</span><a href="#local-6989586621681146369"><span class="hs-identifier hs-var hs-var">e'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; DynFlags -&gt; CoreExpr -&gt; CoreExpr
DynFlags -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.SimpleOpt.html#simpleOptExpr"><span class="hs-identifier hs-var">simpleOptExpr</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681146371"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146372"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1670"></span><span>  </span><span class="annot"><span class="annottext">DsM () -&gt; MaybeT DsM ()
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(DsM () -&gt; MaybeT DsM ()) -&gt; DsM () -&gt; MaybeT DsM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; DsM ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#tracePm"><span class="hs-identifier hs-var">tracePm</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;addCoreCt&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146373"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146372"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146369"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1671"></span><span>  </span><span class="annot"><span class="annottext">StateT Delta (MaybeT DsM) () -&gt; Delta -&gt; MaybeT DsM Delta
forall (m :: * -&gt; *) s a. Monad m =&gt; StateT s m a -&gt; s -&gt; m s
</span><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#execStateT"><span class="hs-identifier hs-var">execStateT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146367"><span class="hs-identifier hs-var">core_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146373"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146369"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146374"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-1672"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1673"></span><span>    </span><span class="hs-comment">-- | Takes apart a 'CoreExpr' and tries to extract as much information about</span><span>
</span><span id="line-1674"></span><span>    </span><span class="hs-comment">-- literals and constructor applications as possible.</span><span>
</span><span id="line-1675"></span><span>    </span><span class="annot"><a href="#local-6989586621681146367"><span class="hs-identifier hs-type">core_expr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1676"></span><span>    </span><span class="hs-comment">-- TODO: Handle newtypes properly, by wrapping the expression in a DataCon</span><span>
</span><span id="line-1677"></span><span>    </span><span class="hs-comment">-- This is the right thing for casts involving data family instances and</span><span>
</span><span id="line-1678"></span><span>    </span><span class="hs-comment">-- their representation TyCon, though (which are not visible in source</span><span>
</span><span id="line-1679"></span><span>    </span><span class="hs-comment">-- syntax). See Note [COMPLETE sets on data families]</span><span>
</span><span id="line-1680"></span><span>    </span><span class="hs-comment">-- core_expr x e | pprTrace &quot;core_expr&quot; (ppr x $$ ppr e) False = undefined</span><span>
</span><span id="line-1681"></span><span>    </span><span id="local-6989586621681146367"><span class="annot"><span class="annottext">core_expr :: Id -&gt; CoreExpr -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146367"><span class="hs-identifier hs-var hs-var">core_expr</span></a></span></span><span> </span><span id="local-6989586621681146366"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146366"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621681146364"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146364"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621681146363"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681146363"><span class="hs-identifier hs-var">_co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146367"><span class="hs-identifier hs-var">core_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146366"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146364"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1682"></span><span>    </span><span class="annot"><a href="#local-6989586621681146367"><span class="hs-identifier hs-var">core_expr</span></a></span><span> </span><span id="local-6989586621681146362"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146362"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621681146360"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621681146360"><span class="hs-identifier hs-var">_t</span></a></span></span><span> </span><span id="local-6989586621681146359"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146359"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146367"><span class="hs-identifier hs-var">core_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146362"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146359"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1683"></span><span>    </span><span class="annot"><a href="#local-6989586621681146367"><span class="hs-identifier hs-var">core_expr</span></a></span><span> </span><span id="local-6989586621681146358"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146358"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146357"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146357"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-1684"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmLit -&gt; Maybe FastString
</span><a href="GHC.HsToCore.PmCheck.Types.html#pmLitAsStringLit"><span class="hs-identifier hs-var">pmLitAsStringLit</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146355"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681146355"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Maybe PmLit
</span><a href="GHC.HsToCore.PmCheck.Types.html#coreExprAsPmLit"><span class="hs-identifier hs-var">coreExprAsPmLit</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146357"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1685"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681146353"><span class="hs-identifier hs-var">expr_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#stringTy"><span class="hs-identifier hs-var">stringTy</span></a></span><span>
</span><span id="line-1686"></span><span>      </span><span class="hs-comment">-- See Note [Representation of Strings in TmState]</span><span>
</span><span id="line-1687"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; String
</span><a href="GHC.Data.FastString.html#unpackFS"><span class="hs-identifier hs-var">unpackFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681146355"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1688"></span><span>          </span><span class="hs-comment">-- We need this special case to break a loop with coreExprAsPmLit</span><span>
</span><span id="line-1689"></span><span>          </span><span class="hs-comment">-- Otherwise we alternate endlessly between [] and &quot;&quot;</span><span>
</span><span id="line-1690"></span><span>          </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; InScopeSet
-&gt; DataCon
-&gt; [CoreExpr]
-&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146350"><span class="hs-identifier hs-var">data_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146358"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="GHC.Types.Var.Env.html#emptyInScopeSet"><span class="hs-identifier hs-var">emptyInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="GHC.Builtin.Types.html#nilDataCon"><span class="hs-identifier hs-var">nilDataCon</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1691"></span><span>          </span><span id="local-6989586621681146347"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681146347"><span class="hs-identifier hs-var">s'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146367"><span class="hs-identifier hs-var">core_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146358"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; [CoreExpr] -&gt; CoreExpr
</span><a href="GHC.Core.Make.html#mkListExpr"><span class="hs-identifier hs-var">mkListExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#charTy"><span class="hs-identifier hs-var">charTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Char -&gt; CoreExpr) -&gt; String -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; CoreExpr
</span><a href="GHC.Core.Make.html#mkCharExpr"><span class="hs-identifier hs-var">mkCharExpr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681146347"><span class="hs-identifier hs-var">s'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1692"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681146345"><span class="annot"><span class="annottext">PmLit
</span><a href="#local-6989586621681146345"><span class="hs-identifier hs-var">lit</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Maybe PmLit
</span><a href="GHC.HsToCore.PmCheck.Types.html#coreExprAsPmLit"><span class="hs-identifier hs-var">coreExprAsPmLit</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146357"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1693"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; PmLit -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146344"><span class="hs-identifier hs-var">pm_lit</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146358"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">PmLit
</span><a href="#local-6989586621681146345"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-1694"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681146343"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621681146343"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146342"><span class="annot"><span class="annottext">_empty_floats :: [FloatBind]
</span><a href="#local-6989586621681146342"><span class="hs-identifier hs-var">_empty_floats</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146341"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146341"><span class="hs-identifier hs-var">dc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146340"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146340"><span class="hs-identifier hs-var">_arg_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146339"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146339"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1695"></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InScopeEnv
-&gt; CoreExpr
-&gt; Maybe (InScopeSet, [FloatBind], DataCon, [Type], [CoreExpr])
HasDebugCallStack =&gt;
InScopeEnv
-&gt; CoreExpr
-&gt; Maybe (InScopeSet, [FloatBind], DataCon, [Type], [CoreExpr])
</span><a href="GHC.Core.SimpleOpt.html#exprIsConApp_maybe"><span class="hs-identifier hs-var">exprIsConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeEnv
forall {b}. (InScopeSet, b -&gt; Unfolding)
</span><a href="#local-6989586621681146338"><span class="hs-identifier hs-var">in_scope_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146357"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1696"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; InScopeSet
-&gt; DataCon
-&gt; [CoreExpr]
-&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146350"><span class="hs-identifier hs-var">data_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146358"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621681146343"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146341"><span class="hs-identifier hs-var">dc</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146339"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1697"></span><span>      </span><span class="hs-comment">-- See Note [Detecting pattern synonym applications in expressions]</span><span>
</span><span id="line-1698"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621681146336"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146336"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146357"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe DataCon
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe DataCon
</span><a href="GHC.Types.Id.html#isDataConId_maybe"><span class="hs-identifier hs-var">isDataConId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146358"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-1699"></span><span>      </span><span class="hs-comment">-- We don't consider DataCons flexible variables</span><span>
</span><span id="line-1700"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; MaybeT DsM Delta) -&gt; StateT Delta (MaybeT DsM) ()
forall (m :: * -&gt; *) s. Monad m =&gt; (s -&gt; m s) -&gt; StateT s m ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#modifyT"><span class="hs-identifier hs-var">modifyT</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681146333"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146333"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addVarCt"><span class="hs-identifier hs-var">addVarCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146333"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146358"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146336"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1701"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1702"></span><span>      </span><span class="hs-comment">-- Any other expression. Try to find other uses of a semantically</span><span>
</span><span id="line-1703"></span><span>      </span><span class="hs-comment">-- equivalent expression and represent them by the same variable!</span><span>
</span><span id="line-1704"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146332"><span class="hs-identifier hs-var">equate_with_similar_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146358"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146357"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1705"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1706"></span><span>        </span><span id="local-6989586621681146353"><span class="annot"><span class="annottext">expr_ty :: Type
</span><a href="#local-6989586621681146353"><span class="hs-identifier hs-var hs-var">expr_ty</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146357"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1707"></span><span>        </span><span id="local-6989586621681146331"><span class="annot"><span class="annottext">expr_in_scope :: InScopeSet
</span><a href="#local-6989586621681146331"><span class="hs-identifier hs-var hs-var">expr_in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; VarSet
</span><a href="GHC.Core.FVs.html#exprFreeVars"><span class="hs-identifier hs-var">exprFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146357"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1708"></span><span>        </span><span id="local-6989586621681146338"><span class="annot"><span class="annottext">in_scope_env :: (InScopeSet, b -&gt; Unfolding)
</span><a href="#local-6989586621681146338"><span class="hs-identifier hs-var hs-var">in_scope_env</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621681146331"><span class="hs-identifier hs-var">expr_in_scope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; b -&gt; Unfolding
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="GHC.Core.html#NoUnfolding"><span class="hs-identifier hs-var">NoUnfolding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1709"></span><span>        </span><span class="hs-comment">-- It's inconvenient to get hold of a global in-scope set</span><span>
</span><span id="line-1710"></span><span>        </span><span class="hs-comment">-- here, but it'll only be needed if exprIsConApp_maybe ends</span><span>
</span><span id="line-1711"></span><span>        </span><span class="hs-comment">-- up substituting inside a forall or lambda (i.e. seldom)</span><span>
</span><span id="line-1712"></span><span>        </span><span class="hs-comment">-- so using exprFreeVars seems fine.   See MR !1647.</span><span>
</span><span id="line-1713"></span><span>
</span><span id="line-1714"></span><span>    </span><span class="hs-comment">-- | The @e@ in @let x = e@ had no familiar form. But we can still see if</span><span>
</span><span id="line-1715"></span><span>    </span><span class="hs-comment">-- see if we already encountered a constraint @let y = e'@ with @e'@</span><span>
</span><span id="line-1716"></span><span>    </span><span class="hs-comment">-- semantically equivalent to @e@, in which case we may add the constraint</span><span>
</span><span id="line-1717"></span><span>    </span><span class="hs-comment">-- @x ~ y@.</span><span>
</span><span id="line-1718"></span><span>    </span><span class="annot"><a href="#local-6989586621681146332"><span class="hs-identifier hs-type">equate_with_similar_expr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1719"></span><span>    </span><span id="local-6989586621681146332"><span class="annot"><span class="annottext">equate_with_similar_expr :: Id -&gt; CoreExpr -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146332"><span class="hs-identifier hs-var hs-var">equate_with_similar_expr</span></a></span></span><span> </span><span id="local-6989586621681146327"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146327"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146326"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146326"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1720"></span><span>      </span><span id="local-6989586621681146325"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146325"><span class="hs-identifier hs-var">rep</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; MaybeT DsM (Id, Delta)) -&gt; StateT Delta (MaybeT DsM) Id
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((Delta -&gt; MaybeT DsM (Id, Delta)) -&gt; StateT Delta (MaybeT DsM) Id)
-&gt; (Delta -&gt; MaybeT DsM (Id, Delta))
-&gt; StateT Delta (MaybeT DsM) Id
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681146323"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146323"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Delta, Id) -&gt; (Id, Delta)
forall a b. (a, b) -&gt; (b, a)
</span><a href="../../base/src/Data.Tuple.html#swap"><span class="hs-identifier hs-var">swap</span></a></span><span> </span><span class="annot"><span class="annottext">((Delta, Id) -&gt; (Id, Delta))
-&gt; MaybeT DsM (Delta, Id) -&gt; MaybeT DsM (Id, Delta)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DsM (Delta, Id) -&gt; MaybeT DsM (Delta, Id)
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Delta -&gt; CoreExpr -&gt; DsM (Delta, Id)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#representCoreExpr"><span class="hs-identifier hs-var">representCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146323"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146326"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1721"></span><span>      </span><span class="hs-comment">-- Note that @rep == x@ if we encountered @e@ for the first time.</span><span>
</span><span id="line-1722"></span><span>      </span><span class="annot"><span class="annottext">(Delta -&gt; MaybeT DsM Delta) -&gt; StateT Delta (MaybeT DsM) ()
forall (m :: * -&gt; *) s. Monad m =&gt; (s -&gt; m s) -&gt; StateT s m ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#modifyT"><span class="hs-identifier hs-var">modifyT</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681146322"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146322"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; Id -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addVarCt"><span class="hs-identifier hs-var">addVarCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146322"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146327"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146325"><span class="hs-identifier hs-var">rep</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1723"></span><span>
</span><span id="line-1724"></span><span>    </span><span class="annot"><a href="#local-6989586621681146321"><span class="hs-identifier hs-type">bind_expr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-1725"></span><span>    </span><span id="local-6989586621681146321"><span class="annot"><span class="annottext">bind_expr :: CoreExpr -&gt; StateT Delta (MaybeT DsM) Id
</span><a href="#local-6989586621681146321"><span class="hs-identifier hs-var hs-var">bind_expr</span></a></span></span><span> </span><span id="local-6989586621681146320"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146320"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1726"></span><span>      </span><span id="local-6989586621681146319"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146319"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM Id -&gt; StateT Delta (MaybeT DsM) Id
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DsM Id -&gt; MaybeT DsM Id
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; DsM Id
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#mkPmId"><span class="hs-identifier hs-var">mkPmId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146320"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1727"></span><span>      </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146367"><span class="hs-identifier hs-var">core_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146319"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681146320"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1728"></span><span>      </span><span class="annot"><span class="annottext">Id -&gt; StateT Delta (MaybeT DsM) Id
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146319"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-1729"></span><span>
</span><span id="line-1730"></span><span>    </span><span class="hs-comment">-- | Look at @let x = K taus theta es@ and generate the following</span><span>
</span><span id="line-1731"></span><span>    </span><span class="hs-comment">-- constraints (assuming universals were dropped from @taus@ before):</span><span>
</span><span id="line-1732"></span><span>    </span><span class="hs-comment">--   1. @a_1 ~ tau_1, ..., a_n ~ tau_n@ for fresh @a_i@</span><span>
</span><span id="line-1733"></span><span>    </span><span class="hs-comment">--   2. @y_1 ~ e_1, ..., y_m ~ e_m@ for fresh @y_i@</span><span>
</span><span id="line-1734"></span><span>    </span><span class="hs-comment">--   3. @x ~ K as ys@</span><span>
</span><span id="line-1735"></span><span>    </span><span class="annot"><a href="#local-6989586621681146350"><span class="hs-identifier hs-type">data_con_app</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1736"></span><span>    </span><span id="local-6989586621681146350"><span class="annot"><span class="annottext">data_con_app :: Id
-&gt; InScopeSet
-&gt; DataCon
-&gt; [CoreExpr]
-&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146350"><span class="hs-identifier hs-var hs-var">data_con_app</span></a></span></span><span> </span><span id="local-6989586621681146318"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146318"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146317"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621681146317"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621681146316"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146316"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span id="local-6989586621681146315"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146315"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1737"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681146314"><span class="annot"><span class="annottext">dc_ex_tvs :: [Id]
</span><a href="#local-6989586621681146314"><span class="hs-identifier hs-var hs-var">dc_ex_tvs</span></a></span></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [Id]
</span><a href="GHC.Core.DataCon.html#dataConExTyCoVars"><span class="hs-identifier hs-var">dataConExTyCoVars</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146316"><span class="hs-identifier hs-var">dc</span></a></span><span>
</span><span id="line-1738"></span><span>          </span><span id="local-6989586621681146312"><span class="annot"><span class="annottext">arty :: Int
</span><a href="#local-6989586621681146312"><span class="hs-identifier hs-var hs-var">arty</span></a></span></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; Int
</span><a href="GHC.Core.DataCon.html#dataConSourceArity"><span class="hs-identifier hs-var">dataConSourceArity</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146316"><span class="hs-identifier hs-var">dc</span></a></span><span>
</span><span id="line-1739"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621681146310"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146310"><span class="hs-identifier hs-var">ex_ty_args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146309"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146309"><span class="hs-identifier hs-var">val_args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [CoreExpr] -&gt; ([CoreExpr], [CoreExpr])
forall b a. [b] -&gt; [a] -&gt; ([a], [a])
</span><a href="GHC.Utils.Misc.html#splitAtList"><span class="hs-identifier hs-var">splitAtList</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146314"><span class="hs-identifier hs-var">dc_ex_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146315"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1740"></span><span>          </span><span id="local-6989586621681146307"><span class="annot"><span class="annottext">ex_tys :: [Type]
</span><a href="#local-6989586621681146307"><span class="hs-identifier hs-var hs-var">ex_tys</span></a></span></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; Type) -&gt; [CoreExpr] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.html#exprToType"><span class="hs-identifier hs-var">exprToType</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146310"><span class="hs-identifier hs-var">ex_ty_args</span></a></span><span>
</span><span id="line-1741"></span><span>          </span><span id="local-6989586621681146305"><span class="annot"><span class="annottext">vis_args :: [CoreExpr]
</span><a href="#local-6989586621681146305"><span class="hs-identifier hs-var hs-var">vis_args</span></a></span></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; [CoreExpr]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">([CoreExpr] -&gt; [CoreExpr]) -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. Int -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681146312"><span class="hs-identifier hs-var">arty</span></a></span><span> </span><span class="annot"><span class="annottext">([CoreExpr] -&gt; [CoreExpr]) -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; [CoreExpr]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146309"><span class="hs-identifier hs-var">val_args</span></a></span><span>
</span><span id="line-1742"></span><span>      </span><span id="local-6989586621681146302"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621681146302"><span class="hs-identifier hs-var">uniq_supply</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MaybeT DsM UniqSupply -&gt; StateT Delta (MaybeT DsM) UniqSupply
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(MaybeT DsM UniqSupply -&gt; StateT Delta (MaybeT DsM) UniqSupply)
-&gt; MaybeT DsM UniqSupply -&gt; StateT Delta (MaybeT DsM) UniqSupply
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) UniqSupply -&gt; MaybeT DsM UniqSupply
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="../../transformers/src/Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env DsGblEnv DsLclEnv) UniqSupply -&gt; MaybeT DsM UniqSupply)
-&gt; IOEnv (Env DsGblEnv DsLclEnv) UniqSupply
-&gt; MaybeT DsM UniqSupply
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env DsGblEnv DsLclEnv) UniqSupply
forall (m :: * -&gt; *). MonadUnique m =&gt; m UniqSupply
</span><a href="GHC.Types.Unique.Supply.html#getUniqueSupplyM"><span class="hs-identifier hs-var">getUniqueSupplyM</span></a></span><span>
</span><span id="line-1743"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681146301"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146301"><span class="hs-identifier hs-var">ex_tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [Id] -&gt; UniqSupply -&gt; (TCvSubst, [Id])
</span><a href="GHC.Core.TyCo.Subst.html#cloneTyVarBndrs"><span class="hs-identifier hs-var">cloneTyVarBndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621681146317"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146314"><span class="hs-identifier hs-var">dc_ex_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621681146302"><span class="hs-identifier hs-var">uniq_supply</span></a></span><span>
</span><span id="line-1744"></span><span>          </span><span id="local-6989586621681146299"><span class="annot"><span class="annottext">ty_cts :: [PmCt]
</span><a href="#local-6989586621681146299"><span class="hs-identifier hs-var hs-var">ty_cts</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [PmCt]
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#equateTys"><span class="hs-identifier hs-var">equateTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Type) -&gt; [Id] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146301"><span class="hs-identifier hs-var">ex_tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681146307"><span class="hs-identifier hs-var">ex_tys</span></a></span><span>
</span><span id="line-1745"></span><span>      </span><span class="hs-comment">-- 1. @a_1 ~ tau_1, ..., a_n ~ tau_n@ for fresh @a_i@. See also #17703</span><span>
</span><span id="line-1746"></span><span>      </span><span class="annot"><span class="annottext">(Delta -&gt; MaybeT DsM Delta) -&gt; StateT Delta (MaybeT DsM) ()
forall (m :: * -&gt; *) s. Monad m =&gt; (s -&gt; m s) -&gt; StateT s m ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#modifyT"><span class="hs-identifier hs-var">modifyT</span></a></span><span> </span><span class="annot"><span class="annottext">((Delta -&gt; MaybeT DsM Delta) -&gt; StateT Delta (MaybeT DsM) ())
-&gt; (Delta -&gt; MaybeT DsM Delta) -&gt; StateT Delta (MaybeT DsM) ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681146298"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146298"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">DsM (Maybe Delta) -&gt; MaybeT DsM Delta
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(DsM (Maybe Delta) -&gt; MaybeT DsM Delta)
-&gt; DsM (Maybe Delta) -&gt; MaybeT DsM Delta
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Delta -&gt; PmCts -&gt; DsM (Maybe Delta)
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addPmCts"><span class="hs-identifier hs-var">addPmCts</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146298"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[PmCt] -&gt; PmCts
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[PmCt]
</span><a href="#local-6989586621681146299"><span class="hs-identifier hs-var">ty_cts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1747"></span><span>      </span><span class="hs-comment">-- 2. @y_1 ~ e_1, ..., y_m ~ e_m@ for fresh @y_i@</span><span>
</span><span id="line-1748"></span><span>      </span><span id="local-6989586621681146297"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146297"><span class="hs-identifier hs-var">arg_ids</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; StateT Delta (MaybeT DsM) Id)
-&gt; [CoreExpr] -&gt; StateT Delta (MaybeT DsM) [Id]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; StateT Delta (MaybeT DsM) Id
</span><a href="#local-6989586621681146321"><span class="hs-identifier hs-var">bind_expr</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681146305"><span class="hs-identifier hs-var">vis_args</span></a></span><span>
</span><span id="line-1749"></span><span>      </span><span class="hs-comment">-- 3. @x ~ K as ys@</span><span>
</span><span id="line-1750"></span><span>      </span><span class="annot"><span class="annottext">Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146296"><span class="hs-identifier hs-var">pm_alt_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146318"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; PmAltCon
</span><a href="GHC.HsToCore.PmCheck.Types.html#PmAltConLike"><span class="hs-identifier hs-var">PmAltConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; ConLike
</span><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-var">RealDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681146316"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146301"><span class="hs-identifier hs-var">ex_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146297"><span class="hs-identifier hs-var">arg_ids</span></a></span><span>
</span><span id="line-1751"></span><span>
</span><span id="line-1752"></span><span>    </span><span class="hs-comment">-- | Adds a literal constraint, i.e. @x ~ 42@.</span><span>
</span><span id="line-1753"></span><span>    </span><span class="annot"><a href="#local-6989586621681146344"><span class="hs-identifier hs-type">pm_lit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmLit"><span class="hs-identifier hs-type">PmLit</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1754"></span><span>    </span><span id="local-6989586621681146344"><span class="annot"><span class="annottext">pm_lit :: Id -&gt; PmLit -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146344"><span class="hs-identifier hs-var hs-var">pm_lit</span></a></span></span><span> </span><span id="local-6989586621681146295"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146295"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146294"><span class="annot"><span class="annottext">PmLit
</span><a href="#local-6989586621681146294"><span class="hs-identifier hs-var">lit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146296"><span class="hs-identifier hs-var">pm_alt_con_app</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146295"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PmLit -&gt; PmAltCon
</span><a href="GHC.HsToCore.PmCheck.Types.html#PmAltLit"><span class="hs-identifier hs-var">PmAltLit</span></a></span><span> </span><span class="annot"><span class="annottext">PmLit
</span><a href="#local-6989586621681146294"><span class="hs-identifier hs-var">lit</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1755"></span><span>
</span><span id="line-1756"></span><span>    </span><span class="hs-comment">-- | Adds the given constructor application as a solution for @x@.</span><span>
</span><span id="line-1757"></span><span>    </span><span class="annot"><a href="#local-6989586621681146296"><span class="hs-identifier hs-type">pm_alt_con_app</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#PmAltCon"><span class="hs-identifier hs-type">PmAltCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="GHC.HsToCore.PmCheck.Types.html#Delta"><span class="hs-identifier hs-type">Delta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-type">MaybeT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#DsM"><span class="hs-identifier hs-type">DsM</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1758"></span><span>    </span><span id="local-6989586621681146296"><span class="annot"><span class="annottext">pm_alt_con_app :: Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; StateT Delta (MaybeT DsM) ()
</span><a href="#local-6989586621681146296"><span class="hs-identifier hs-var hs-var">pm_alt_con_app</span></a></span></span><span> </span><span id="local-6989586621681146293"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146293"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681146292"><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146292"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621681146291"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146291"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681146290"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146290"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Delta -&gt; MaybeT DsM Delta) -&gt; StateT Delta (MaybeT DsM) ()
forall (m :: * -&gt; *) s. Monad m =&gt; (s -&gt; m s) -&gt; StateT s m ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#modifyT"><span class="hs-identifier hs-var">modifyT</span></a></span><span> </span><span class="annot"><span class="annottext">((Delta -&gt; MaybeT DsM Delta) -&gt; StateT Delta (MaybeT DsM) ())
-&gt; (Delta -&gt; MaybeT DsM Delta) -&gt; StateT Delta (MaybeT DsM) ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681146289"><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146289"><span class="hs-identifier hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Delta -&gt; Id -&gt; PmAltCon -&gt; [Id] -&gt; [Id] -&gt; MaybeT DsM Delta
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#addConCt"><span class="hs-identifier hs-var">addConCt</span></a></span><span> </span><span class="annot"><span class="annottext">Delta
</span><a href="#local-6989586621681146289"><span class="hs-identifier hs-var">delta</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681146293"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">PmAltCon
</span><a href="#local-6989586621681146292"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146291"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681146290"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1759"></span><span>
</span><span id="line-1760"></span><span class="hs-comment">-- | Like 'modify', but with an effectful modifier action</span><span>
</span><span id="line-1761"></span><span id="local-6989586621681147590"><span id="local-6989586621681147591"><span class="annot"><a href="GHC.HsToCore.PmCheck.Oracle.html#modifyT"><span class="hs-identifier hs-type">modifyT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681147591"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681147590"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681147591"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681147590"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-type">StateT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681147590"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681147591"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-1762"></span><span id="modifyT"><span class="annot"><span class="annottext">modifyT :: forall (m :: * -&gt; *) s. Monad m =&gt; (s -&gt; m s) -&gt; StateT s m ()
</span><a href="GHC.HsToCore.PmCheck.Oracle.html#modifyT"><span class="hs-identifier hs-var hs-var">modifyT</span></a></span></span><span> </span><span id="local-6989586621681146282"><span class="annot"><span class="annottext">s -&gt; m s
</span><a href="#local-6989586621681146282"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(s -&gt; m ((), s)) -&gt; StateT s m ()
forall s (m :: * -&gt; *) a. (s -&gt; m (a, s)) -&gt; StateT s m a
</span><a href="../../transformers/src/Control.Monad.Trans.State.Strict.html#StateT"><span class="hs-identifier hs-var">StateT</span></a></span><span> </span><span class="annot"><span class="annottext">((s -&gt; m ((), s)) -&gt; StateT s m ())
-&gt; (s -&gt; m ((), s)) -&gt; StateT s m ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(s -&gt; ((), s)) -&gt; m s -&gt; m ((), s)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">,</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(m s -&gt; m ((), s)) -&gt; (s -&gt; m s) -&gt; s -&gt; m ((), s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; m s
</span><a href="#local-6989586621681146282"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-1763"></span><span>
</span><span id="line-1764"></span><span class="hs-comment">{- Note [Detecting pattern synonym applications in expressions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At the moment we fail to detect pattern synonyms in scrutinees and RHS of
guards. This could be alleviated with considerable effort and complexity, but
the returns are meager. Consider:

    pattern P
    pattern Q
    case P 15 of
      Q _  -&gt; ...
      P 15 -&gt;

Compared to the situation where P and Q are DataCons, the lack of generativity
means we could never flag Q as redundant. (also see Note [Undecidable Equality
for PmAltCons] in PmTypes.) On the other hand, if we fail to recognise the
pattern synonym, we flag the pattern match as inexhaustive. That wouldn't happen
if we had knowledge about the scrutinee, in which case the oracle basically
knows &quot;If it's a P, then its field is 15&quot;.

This is a pretty narrow use case and I don't think we should to try to fix it
until a user complains energetically.
-}</span><span>
</span><span id="line-1786"></span></pre></body></html>